https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82040
Bug ID: 82040 Summary: ICE with -Wbool-operation and ~ Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jorrit at jorrit dot de Target Milestone: --- The following code, when compiled with g++ -std=c++11 -Wbool-operation standardtest_bool.ii -S -o /dev/null results in the following ICE: Internal compiler error: Error reporting routines re-entered. standardtest_bool.ii: ======================================== template <class c> decltype(~c{}) call() { return ~false; } template int call<bool>(); ======================================== This does not happen without -Wbool-operation. This was originally observed with "g++-7 (Debian 7.1.0-9) 7.1.0" from Debian testing (buster). According to https://godbolt.org/g/pYgpua, this is still present in "g++ (GCC-Explorer-Build) 8.0.0 20170830 (experimental)" g++-6 does not seem to have -Wbool-operation, so this does not apply. Here is the full output, obtained with g++-7 from Debian testing (godbolt seems to suppress the backtrace): ======================================== -*- mode: compilation; default-directory: "/builds/core/dune-common/build-cmake/dune/common/simd/test/gcc-6/hand/" -*- Compilation started at Wed Aug 30 17:13:07 /usr/bin/g++-7 -std=c++11 -Wbool-operation standardtest_bool.ii -S -o /dev/null standardtest_bool.ii: In function 'decltype (~ c{}) call()': standardtest_bool.ii:1:52: warning: '~' on an expression of type bool [-Wbool-operation] template <class c> decltype(~c{}) call() { return ~false; } ^~~~~ standardtest_bool.ii:1:52: note: did you mean to use logical not ('!')? standardtest_bool.ii: In substitution of 'template<class c> decltype (~ c{}) call() [with c = bool]': standardtest_bool.ii:2:25: required from here standardtest_bool.ii:1:29: warning: '~' on an expression of type bool [-Wbool-operation] template <class c> decltype(~c{}) call() { return ~false; } ^~~~ standardtest_bool.ii:1:29: note: did you mean to use logical not ('!')? standardtest_bool.ii: In substitution of 'template<class c> decltype (~ c{}) call() [with c = bool]': standardtest_bool.ii:2:25: required from here standardtest_bool.ii:1:29: warning: '~' on an expression of type bool [-Wbool-operation] standardtest_bool.ii:1:29: note: did you mean to use logical not ('!')? standardtest_bool.ii: At global scope: standardtest_bool.ii:1:29: warning: '~' on an expression of type bool [-Wbool-operation] standardtest_bool.ii:1:29: note: did you mean to use logical not ('!')? ' Internal compiler error: Error reporting routines re-entered. 0x668771 cp_build_unary_op(tree_code, tree_node*, bool, int) ../../src/gcc/cp/typeck.c:5930 0x5b252f build_new_op_1 ../../src/gcc/cp/call.c:5995 0x5b2f6e build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) ../../src/gcc/cp/call.c:6026 0x66738f build_x_unary_op(unsigned int, tree_code, cp_expr, int) ../../src/gcc/cp/typeck.c:5425 0x5ee034 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../src/gcc/cp/pt.c:16876 0x5e28d5 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../src/gcc/cp/pt.c:14143 0x5e28d5 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.c:14143 0x620982 dump_template_bindings ../../src/gcc/cp/error.c:353 0x620982 dump_substitution ../../src/gcc/cp/error.c:1494 0x621242 dump_substitution ../../src/gcc/cp/cp-tree.h:5572 0x621242 dump_function_decl ../../src/gcc/cp/error.c:1649 0x6263e1 decl_to_string ../../src/gcc/cp/error.c:3033 0x6263e1 cp_printer ../../src/gcc/cp/error.c:3610 0x11c01a2 pp_format(pretty_printer*, text_info*) ../../src/gcc/pretty-print.c:679 0x11c0a10 pp_format_verbatim(pretty_printer*, text_info*) ../../src/gcc/pretty-print.c:738 0x11c0ae4 pp_verbatim(pretty_printer*, char const*, ...) ../../src/gcc/pretty-print.c:939 0x61fa85 print_instantiation_full_context ../../src/gcc/cp/error.c:3388 0x624a68 maybe_print_instantiation_context ../../src/gcc/cp/error.c:3536 0x624a68 cp_diagnostic_starter ../../src/gcc/cp/error.c:3229 0x11b983e diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../src/gcc/diagnostic.c:962 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions. Compilation exited abnormally with code 1 at Wed Aug 30 17:13:07 ======================================== Convenience link to our bug: https://gitlab.dune-project.org/core/dune-common/issues/84