Command line: $ g++ -std=gnu++0x -flto testcase.C testcase.C:2:12: internal compiler error: tree code 'lang_type' is not supported in gimple streams -------- testcase.C -------- typedef decltype(nullptr) nullptr_t; nullptr_t a; ---------------------------- Tested revisions: r160687 - crash r159696 - crash r159387 - crash r158969 - nullptr is not recognized The problem is that almost any code using C++0x mode fails to compile with -flto -fkeep-inline-functions.
Confirmed. It isn't valid for LANG_TYPE node to leak to the middle-end. gdb) call debug_tree (expr) <lang_type 0xb77a3180 nullptr_t unsigned SI size <integer_cst 0xb7722288 type <integer_type 0xb7739060 bit_size_type> constant 32> unit size <integer_cst 0xb77220c0 type <integer_type 0xb7739000 unsigned int> constant 4> align 8 symtab 0 alias set -1 canonical type 0xb7799000>
*** Bug 45789 has been marked as a duplicate of this bug. ***
This btw fails nearly all libstdc++ tests when built with -flto. Jason, is there no way to avoid lang_type to leak into the middle-end like this? Why do we need to use lang_type for nullptr and cannot use void * with some lang-specific flag? This really breaks LTO badly for 4.6, so if it cannot be resolved in the FE I guess I'll just drop all lang_type nodes at streaming time replacing them with ptr_type_node (ugh).
Another way to handle it in LTO would be to simply stream LANG_TYPE, assuming it must be completely opaque to the rest of the compiler anyway. Probably better than the ptr_type_node idea. I will give that a try if no other ideas pop up.
I have a patch.
New problems. typedef decltype(nullptr) nullptr_t; class shared_ptr { public: shared_ptr(nullptr_t __p); }; shared_ptr p = nullptr; exposes a nullptr constant (INTEGER_CST of LANG_TYPE). Of course build_int_cst_wide doesn't like this at all. From cp/decl.c:cxx_init_decl_processing(): nullptr_node = make_node (INTEGER_CST); TREE_TYPE (nullptr_node) = nullptr_type_node; :( One more reason to make NULLPTR_TYPE a regular middle-end tree code.
Created attachment 22014 [details] WIP patch Work-in-progress for the just-stream-lang-type idea. Adding odd LANG_TYPE handling to the middle-end in various places.
Author: rguenth Date: Thu Oct 14 11:59:47 2010 New Revision: 165462 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165462 Log: 2010-10-14 Richard Guenther <rguenther@suse.de> PR lto/44561 * tree.def (NULLPTR_TYPE): New tree code. * dbxout.c (dbxout_type): Handle NULLPTR_TYPE. * dwarf2out.c (is_base_type): Likewise. (gen_type_die_with_usage): Likewise. * sdbout.c (plain_type_1): Likewise. * tree.c (build_int_cst_wide): Likewise. * gimple.c (gimple_types_compatible_p_1): NULLPTR_TYPE types are equal. cp/ * cp-tree.h (NULLPTR_TYPE_P): Adjust. * decl.c (cxx_init_decl_processing): Build a NULLPTR_TYPE node, use build_int_cst. * error.c (dump_type): Handle NULLPTR_TYPE. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. * mangle.c (write_type): Likewise. * name-lookup.c (arg_assoc_type): Likewise. * rtti.c (typeinfo_in_lib_p): Likewise. * pt.c (tsubst): Likewise. * g++.dg/lto/20101010-3_0.C: New testcase. * g++.dg/lto/20101010-4_0.C: Likewise. Added: trunk/gcc/testsuite/g++.dg/lto/20101010-3_0.C trunk/gcc/testsuite/g++.dg/lto/20101010-4_0.C Modified: trunk/gcc/ChangeLog trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/error.c trunk/gcc/cp/mangle.c trunk/gcc/cp/name-lookup.c trunk/gcc/cp/pt.c trunk/gcc/cp/rtti.c trunk/gcc/dbxout.c trunk/gcc/dwarf2out.c trunk/gcc/gimple.c trunk/gcc/sdbout.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree.c trunk/gcc/tree.def
Fixed.