Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Error due to danling-reference warning with -Werror #7749

Closed
jparsert opened this issue Jun 4, 2023 · 1 comment · Fixed by #8368
Closed

Compilation Error due to danling-reference warning with -Werror #7749

jparsert opened this issue Jun 4, 2023 · 1 comment · Fixed by #8368

Comments

@jparsert
Copy link

jparsert commented Jun 4, 2023

Pulling the develop branch and change into cbmc directory and executing the following commands:

git submodule update --init
cmake -S . -Bbuild
cd build
make

I get the following errors:

.../cbmc/src/goto-symex/goto_symex.cpp:350:18: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 350 | const symbolt &return_symbol = get_fresh_aux_symbol( ...

and

.../cbmc/src/solvers/smt2/smt2_conv.cpp:998:37: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 998 | for(auto ch : id2string(identifier))
I suspect these are not the only errors if I did not abort the compilation.

After adding "-Wno-dangling-reference" I got the following errors:
.../src/util/cmdline.h:75:16: error: ‘virtual bool cmdlinet::parse(int, const char**, const char*)’ was hidden [-Werror=overloaded-virtual=] 75 | virtual bool parse(int argc, const char **argv, const char *optstring);

Working with linux6.3-4-1 Manjaro and GCC 13.1.1

@jiripospisil
Copy link

Getting something similar on Arch Linux (GCC 14.1.1 20240522) with the latest release (6.0.0):

g++ -c -DSATCHECK_MINISAT2 -MMD -MP -std=c++17 -DHAVE_MINISAT2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/cbmc/src=/usr/src/debug/cbmc -flto=auto -Wall -pedantic -Werror -Wswitch-enum -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-unknown-warning-option  -I .. -o c_nondet_symbol_factory.o c_nondet_symbol_factory.cpp
c_nondet_symbol_factory.cpp: In function ‘symbol_exprt c_nondet_symbol_factory(code_blockt&, symbol_table_baset&, irep_idt, const typet&, const source_locationt&, const c_object_factory_parameterst&, lifetimet)’:
c_nondet_symbol_factory.cpp:212:18: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  212 |   const symbolt &main_symbol = get_fresh_aux_symbol(
      |                  ^~~~~~~~~~~
c_nondet_symbol_factory.cpp:212:52: note: the temporary was destroyed at the end of the full expression ‘get_fresh_aux_symbol((* & type), (* & id2string(goto_functionst::entry_point()())), (* & id2string(base_name)), (* & loc), ID_C, (* & symbol_table))’
  212 |   const symbolt &main_symbol = get_fresh_aux_symbol(
      |                                ~~~~~~~~~~~~~~~~~~~~^
  213 |     type,
      |     ~~~~~                                           
  214 |     id2string(goto_functionst::entry_point()),
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      
  215 |     id2string(base_name),
      |     ~~~~~~~~~~~~~~~~~~~~~                           
  216 |     loc,
      |     ~~~~                                            
  217 |     ID_C,
      |     ~~~~~                                           
  218 |     symbol_table);
      |     ~~~~~~~~~~~~~                                   
At top level:
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
make[1]: *** [../common:231: c_nondet_symbol_factory.o] Error 1

The same error also occurs at:

goto_convert.cpp:164
c_nondet_symbol_factory.cpp:212
goto_convert_side_effect.cpp:408
goto_convert_side_effect.cpp:454
goto_symex.cpp:350
shadow_memory.cpp:74
symex_dereference.cpp:218

More:

g++ -c -DSATCHECK_MINISAT2 -DHAVE_MINISAT2 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MMD -MP -std=c++17 -DHAVE_MINISAT2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/cbmc/src=/usr/src/debug/cbmc -flto=auto -Wall -pedantic -Werror -Wswitch-enum -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-unknown-warning-option  -I ..    -I ../../minisat-2.2.1        -o smt2/smt2_conv.o smt2/smt2_conv.cpp
smt2/smt2_conv.cpp: In function ‘bool is_smt2_simple_identifier(const std::string&)’:
smt2/smt2_conv.cpp:1011:37: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
 1011 |   for(auto ch : id2string(identifier))
      |                                     ^
smt2/smt2_conv.cpp:1011:26: note: the temporary was destroyed at the end of the full expression ‘id2string(dstringt((* & identifier)))’
 1011 |   for(auto ch : id2string(identifier))
      |                 ~~~~~~~~~^~~~~~~~~~~~
g++ -c -DSATCHECK_MINISAT2 -MMD -MP -std=c++17 -DHAVE_MINISAT2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/cbmc/src=/usr/src/debug/cbmc -flto=auto -Wall -pedantic -Werror -Wswitch-enum -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-unknown-warning-option  -I .. -o value_set_fi.o value_set_fi.cpp
value_set_fi.cpp: In member function ‘void value_set_fit::get_value_set_rec(const exprt&, object_mapt&, bool&, const std::string&, const typet&, const namespacet&, gvs_recursion_sett&) const’:
value_set_fi.cpp:446:26: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  446 |       const std::string &component_name =
      |                          ^~~~~~~~~~~~~~
value_set_fi.cpp:447:18: note: the temporary was destroyed at the end of the full expression ‘id2string(member_exprt::get_component_name() const())’
  447 |         id2string(to_member_expr(expr).get_component_name());
      |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -c -DSATCHECK_MINISAT2 -MMD -MP -std=c++17 -DHAVE_MINISAT2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/cbmc/src=/usr/src/debug/cbmc -flto=auto -Wall -pedantic -Werror -Wswitch-enum -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-unknown-warning-option  -I .. -o interpreter.o interpreter.cpp
interpreter.cpp: In member function ‘void interpretert::execute_function_call()’:
interpreter.cpp:754:19: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
  754 |   const irep_idt &identifier = address_to_symbol(address).get_identifier();
      |                   ^~~~~~~~~~
interpreter.cpp:754:73: note: the temporary was destroyed at the end of the full expression ‘interpretert::address_to_symbol(const mp_integer&) const(address).symbol_exprt::get_identifier()’
  754 |   const irep_idt &identifier = address_to_symbol(address).get_identifier();
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

There are others but the error is pretty much the same every time.

tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code), but still require working around.
These warnings also affect CaDiCaL builds, which in turn requires us to
upgrade to version 2.0.0, where workarounds have been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
tautschnig added a commit to tautschnig/cbmc that referenced this issue Jul 5, 2024
GCC 14 adds new warnings. Those are largely spurious (perhaps with
exception of the interpreter code and unit tests), but still require
working around.  These warnings also affect CaDiCaL builds, which in
turn requires us to upgrade to version 2.0.0, where workarounds have
been added.

Fixes: diffblue#7749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants