http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55443



             Bug #: 55443

           Summary: ICE for some placement new expressions inside noexcept

                    operator

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: vlu...@gmx.de





Created attachment 28762

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28762

Preprocessed c++ source using placement new inside noexcept



The attached code causes an ICE with both GCC 4.7.2 and a GCC 4.8.0 prerelease.

Output of "c++ -v" for the latter is:

-----------------------------------------------------------

Using built-in specs.

COLLECT_GCC=/home/lima/vanilla_installs/gcc_and_tools/bin/c++

COLLECT_LTO_WRAPPER=/home/lima/vanilla_installs/gcc_and_tools/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ../gcc_svn/configure

--prefix=/home/lima/vanilla_installs/gcc_and_tools --enable-__cxa_atexit

--enable-languages=c,c++ --disable-nls --disable-multilib

Thread model: posix

gcc version 4.8.0 20121122 (experimental) (GCC)

-----------------------------------------------------------



The command line was: 

c++ -std=c++0x noexcept_operator_constexpr.ice.ii

That triggers the following output:

-------------------------------------------------------

noexcept_operator_constexpr.ice.cc: In function 'int main()':

noexcept_operator_constexpr.ice.cc:9:30:   in constexpr expansion of

'((X*)<anonymous>)->X::X()'

noexcept_operator_constexpr.ice.cc:9:31: internal compiler error: in

cxx_eval_call_expression, at cp/semantics.c:6687

 };

                               ^

0x6b742f cxx_eval_call_expression

        ../../gcc_svn/gcc/cp/semantics.c:6686

0x6b05bb cxx_eval_constant_expression

        ../../gcc_svn/gcc/cp/semantics.c:7672

0x6b1f28 is_sub_constant_expr(tree_node*)

        ../../gcc_svn/gcc/cp/semantics.c:8047

0x6732a7 check_noexcept_r

        ../../gcc_svn/gcc/cp/except.c:1162

0xcaa5bb walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),

void*, pointer_set_t*, tree_node* (*)(tree_node**, int*, tree_node*

(*)(tree_node**, int*, void*), void*, pointer_set_t*))

        ../../gcc_svn/gcc/tree.c:10655

0xcaaa9d walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),

void*, pointer_set_t*, tree_node* (*)(tree_node**, int*, tree_node*

(*)(tree_node**, int*, void*), void*, pointer_set_t*))

        ../../gcc_svn/gcc/tree.c:10909

0xcaaa9d walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),

void*, pointer_set_t*, tree_node* (*)(tree_node**, int*, tree_node*

(*)(tree_node**, int*, void*), void*, pointer_set_t*))

        ../../gcc_svn/gcc/tree.c:10909

0xcaa0e4 walk_tree_without_duplicates_1(tree_node**, tree_node*

(*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*,

tree_node* (*)(tree_node**, int*, void*), void*, pointer_set_t*))

        ../../gcc_svn/gcc/tree.c:10936

0x672e6d expr_noexcept_p(tree_node*, int)

        ../../gcc_svn/gcc/cp/except.c:1239

0x673004 finish_noexcept_expr(tree_node*, int)

        ../../gcc_svn/gcc/cp/except.c:1224

0x62d116 cp_parser_unary_expression

        ../../gcc_svn/gcc/cp/parser.c:6554

0x62db17 cp_parser_binary_expression

        ../../gcc_svn/gcc/cp/parser.c:7344

0x62dfb6 cp_parser_assignment_expression

        ../../gcc_svn/gcc/cp/parser.c:7569

0x62fee2 cp_parser_expression

        ../../gcc_svn/gcc/cp/parser.c:7720

0x6305fe cp_parser_expression_statement

        ../../gcc_svn/gcc/cp/parser.c:9000

0x626557 cp_parser_statement

        ../../gcc_svn/gcc/cp/parser.c:8852

0x6277de cp_parser_statement_seq_opt

        ../../gcc_svn/gcc/cp/parser.c:9118

0x627926 cp_parser_compound_statement

        ../../gcc_svn/gcc/cp/parser.c:9072

0x638e33 cp_parser_function_body

        ../../gcc_svn/gcc/cp/parser.c:17648

0x638e33 cp_parser_ctor_initializer_opt_and_function_body

        ../../gcc_svn/gcc/cp/parser.c:17684

Please submit a full bug report,

with preprocessed source if appropriate.

Please include the complete backtrace with any bug report.

See <http://gcc.gnu.org/bugs.html> for instructions.

-----------------------------------------------------------



Some variations of the attached code crash the compiler too. One of them is:

------------------------------------------------------------

#include <stddef.h>



struct X {

  X() = default;



  X(int);



  void* operator new(size_t, void*) noexcept;

};



X x;



bool b = noexcept(new(0) X);

-----------------------------------------------------------------



With respect to the code snippet immediately above, the compiler does not

produce an ICE when any single item of the following is applied:

1. Removing the variable definition of "x".

2. Changing the variable definition to "X x{0};".

3. Removing the noexcept specifier from the operator new declaration.

4. Removing the constructor declaration "X(int);"

5. Changing the final line to "bool b = noexcept(new(0) X{});".



(Doing more than one of the above also seems to make the ICE go away, but I

have not tested every combination.)

Reply via email to