[Bug c++/41863] New: [4.5 Regression] segfault with sizeof in template parameter

foom at fuhm dot net gcc-bugzilla@gcc.gnu.org
Thu Oct 29 03:34:00 GMT 2009


GCC 4.5 appears to fail when using sizeof(member-of-templated-type) inside a
template parameter.

I have tested the Debian gcc-snapshot 20090923-1 amd64 package, 20091010-1
i386, and Ubuntu gcc-snapshot 20091018-1 amd64. All exhibit the same behavior.
g++-4.4 works fine, however.

Changing to "sizeof(m_foo)" to "sizeof(T)" also fixes the problem.

File /tmp/test.cpp:
===CUT===
template<int X> struct Bar {
};

template<typename T>
class Foo {
    T m_foo;
    void crash() {
        Bar<sizeof(m_foo)> bar;
    }
};
===CUT===

$ g++ -c /tmp/test.cpp

/tmp/test.cpp: In member function 'void Foo<T>::crash()':
/tmp/test.cpp:8:26: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-snapshot/README.Bugs> for instructions.


-- 
           Summary: [4.5 Regression] segfault with sizeof in template
                    parameter
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: foom at fuhm dot net
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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



More information about the Gcc-bugs mailing list