https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84125

            Bug ID: 84125
           Summary: [8 Regression] ICE in generic lambda when
                    static_assert argument is implicitly converted to bool
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: benni.buch at gmail dot com
  Target Milestone: ---

struct X{ constexpr operator bool()const{ return true; } };

int main(){
    [](auto){
        static_assert(X{});
    };
}


$ g++ -std=c++14 main.cpp 
main.cpp: In lambda function:
main.cpp:5:27: internal compiler error: in build_address, at cp/typeck.c:5738
         static_assert(X{});
                           ^
0x63818d build_address(tree_node*)
        ../../gcc/gcc/cp/typeck.c:5738
0x7f1385 add_function_candidate
        ../../gcc/gcc/cp/call.c:2168
0x7f268b add_candidates
        ../../gcc/gcc/cp/call.c:5527
0x7ee84e add_candidates
        ../../gcc/gcc/cp/call.c:5438
0x7ee84e build_user_type_conversion_1
        ../../gcc/gcc/cp/call.c:3851
0x7efbd1 implicit_conversion
        ../../gcc/gcc/cp/call.c:1899
0x7ec420 perform_implicit_conversion_flags(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:10542
0x976168 finish_static_assert(tree_node*, tree_node*, unsigned int, bool)
        ../../gcc/gcc/cp/semantics.c:8645
0x8dde71 cp_parser_static_assert
        ../../gcc/gcc/cp/parser.c:13893
0x90877e cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:12823
0x908e29 cp_parser_declaration_statement
        ../../gcc/gcc/cp/parser.c:12420
0x8e722b cp_parser_statement
        ../../gcc/gcc/cp/parser.c:10869
0x8e8170 cp_parser_statement_seq_opt
        ../../gcc/gcc/cp/parser.c:11218
0x8e96ae cp_parser_lambda_body
        ../../gcc/gcc/cp/parser.c:10632
0x8e96ae cp_parser_lambda_expression
        ../../gcc/gcc/cp/parser.c:10137
0x8e96ae cp_parser_primary_expression
        ../../gcc/gcc/cp/parser.c:5257
0x8fb40c cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:7026
0x8fbfe0 cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:8281
0x8dcb5f cp_parser_cast_expression
        ../../gcc/gcc/cp/parser.c:9049
0x8dd36a cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:9150
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ g++ --version
g++ (GCC) 8.0.1 20180130 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Boost.Hana test suite has some test cases that run into this!


Known to work with GCC 6.3:

$ g++-6 --version
g++-6 (Ubuntu/Linaro 6.3.0-18ubuntu2~16.04) 6.3.0 20170519
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to