Skip to content
Snippets Groups Projects
Commit ccd4e774 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

Fix FP compilation warning in box_select

When I bumped ZSTD (see the next commit), Fedora 34, 35, 36 workflows
started to fail with the following error:

NO_WRAP
In function ‘txn_commit_ro_stmt’,
    inlined from ‘box_select’ at /build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc:2569:20:
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/txn.h:812:32: error: ‘svp.region’ may be used uninitialized [-Werror=maybe-uninitialized]
  812 |                 region_truncate(svp->region, svp->region_used);
      |                                ^
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc: In function ‘box_select’:
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc:2523:33: note: ‘svp.region’ was declared here
 2523 |         struct txn_ro_savepoint svp;
      |                                 ^
In function ‘txn_commit_ro_stmt’,
    inlined from ‘box_select’ at /build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc:2569:20:
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/txn.h:812:32: error: ‘svp.region_used’ may be used uninitialized [-Werror=maybe-uninitialized]
  812 |                 region_truncate(svp->region, svp->region_used);
      |                                ^
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc: In function ‘box_select’:
/build/usr/src/debug/tarantool-2.11.0~entrypoint.306.dev/src/box/box.cc:2523:33: note: ‘svp.region_used’ was declared here
 2523 |         struct txn_ro_savepoint svp;
      |                                 ^
NO_WRAP

This is clearly a false-positive error, because we initialize and use
txn_ro_savepoint iff txn == NULL. Interestingly, we use txn_ro_savepoint
in exactly the same way in box_index_get, but get no error there. Looks
like a compiler bug. I failed to reproduce the issue locally in a Docker
container.

Let's suppress this false-positive error by always initializing
txn_ro_savepoint in txn_begin_ro_stmt - it's cheap.

NO_DOC=compilation fix
NO_TEST=compilation fix
NO_CHANGELOG=compilation fix
parent 13cc57e3
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment