This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45603] New: cc1plus crashes in "build_addr_func"


The following code crashes cc1plus (tested with 4.3, 4.4 and trunk revision
164022) inside "build_addr_func":

//start code (test.cpp)
template<typename T>
struct Singleton
{
    static T* get()
    {
        static T instance;
        return &instance;
    }

    ~Singleton() {}
};

struct Foo : Singleton<Foo>
{
};

extern "C" int __cxa_guard_acquire()
{
}

void foo()
{
    Foo::get();
}
//end code

It does not crash when you remove ~Singleton or __cxa_guard_acquire.

Complete output from GCC:

$ /usr/local/bin/g++ -v test.cpp 
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure : (reconfigured) ./configure
--enable-languages=c,c++,fortran,java,objc --no-create --no-recursion
Thread model: posix
gcc version 4.6.0 20100908 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.0/cc1plus -quiet -v -D_GNU_SOURCE
test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=pentiumpro -auxbase
test -version -o /tmp/ccpxf6oX.s
GNU C++ (GCC) version 4.6.0 20100908 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.6.0 20100908 (experimental), GMP version
4.3.2, MPFR version 2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0

/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/i686-pc-linux-gnu

/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/../../../../include/c++/4.6.0/backward
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/include
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.6.0/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.6.0 20100908 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.6.0 20100908 (experimental), GMP version
4.3.2, MPFR version 2.4.2-p1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 5f4083fa939042ee12c0a6b9cb546b1b
test.cpp: In static member function ?static T* Singleton<T>::get() [with T =
Foo]?:
test.cpp:23:10:   instantiated from here
test.cpp:6:18: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

And the backtrace from cc1plus:

#0  build_addr_func (function=0x0) at ../.././gcc/cp/call.c:261
#1  0x080ced47 in build_call_a (function=0x0, n=1, argarray=0xbffff220) at
../.././gcc/cp/call.c:312
#2  0x080cf486 in build_call_n (function=0x0, n=1) at ../.././gcc/cp/call.c:298
#3  0x0810840b in expand_static_init (decl=0xb7f4a840, init=0x0,
init_const_expr_p=0 '\000', asmspec_tree=<value optimized out>, flags=0) at
../.././gcc/cp/decl.c:6485
#4  cp_finish_decl (decl=0xb7f4a840, init=0x0, init_const_expr_p=0 '\000',
asmspec_tree=<value optimized out>, flags=0) at ../.././gcc/cp/decl.c:6045
#5  0x0812ef4f in tsubst_expr (t=<value optimized out>, args=0xb7f4b000,
complain=3, in_decl=0xb7ec6f30, integral_constant_expression_p=0 '\000') at
../.././gcc/cp/pt.c:11733
#6  0x0812fea5 in tsubst_expr (t=<value optimized out>, args=0xb7f4b000,
complain=3, in_decl=0xb7ec6f30, integral_constant_expression_p=0 '\000') at
../.././gcc/cp/pt.c:11634
#7  0x0812ee32 in tsubst_expr (t=0xb7eab678, args=0xb7f4b000, complain=3,
in_decl=0xb7ec6f30, integral_constant_expression_p=0 '\000') at
../.././gcc/cp/pt.c:11795
#8  0x0815d282 in instantiate_decl (d=<value optimized out>, defer_ok=<value
optimized out>, expl_inst_class_mem_p=0 '\000') at ../.././gcc/cp/pt.c:17007
#9  0x08166af8 in instantiate_pending_templates (retries=0) at
../.././gcc/cp/pt.c:17104
#10 0x0819a188 in cp_write_global_declarations () at
../.././gcc/cp/decl2.c:3637
#11 0x08598233 in compile_file (argc=2, argv=0xbffff714) at
../.././gcc/toplev.c:984
#12 do_compile (argc=2, argv=0xbffff714) at ../.././gcc/toplev.c:2411
#13 toplev_main (argc=2, argv=0xbffff714) at ../.././gcc/toplev.c:2452
#14 0x082c7beb in main (argc=2, argv=0xbffff714) at ../.././gcc/main.c:36


-- 
           Summary: cc1plus crashes in "build_addr_func"
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jobnoorman at gmail dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]