Bug 67336 - gcc segfaults on sizeof( namespace::templateClassWithoutType )
gcc segfaults on sizeof( namespace::templateClassWithoutType )
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-06-22 17:48 EDT by Aaron Cameron
Modified: 2007-04-18 12:43 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-02 17:30:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Aaron Cameron 2002-06-22 17:48:14 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.5 (X11; Linux i686; U;) Gecko/20020606

Description of problem:
G++ crashes while compiling code that tries to take the sizeof() a template
class defined in a seperate namespace if that template class hasn't been given a
proper type.  This shouldn't compile anyway, but it shouldn't segfault the
compiler either.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Simply compiling the following example code:

namespace anywhere {
        template <class T_test_t>
        class cTestClass{};
void main() { sizeof(anywhere::cTestClass); }

Actual Results:  Compiler Segmentation faults instead of erroring:

gccCrash.C: In function `int main ()':
gccCrash.C:15: Internal error: Segmentation fault.
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

Expected Results:  Compiler should error as it does when the template isn't in
its own namespace:

gccCrash.C: In function `int main ()':
gccCrash.C:15: use of class template `template <T_test_t> class 
cTestClass' as expression

Additional info:

Always happens with: gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
I don't have the resources to test other versions.
Comment 1 Alan Cox 2002-12-15 16:44:11 EST
Still present in 8.0 (though g++ 3.2 cares that you have int main() not void
and so initially it seemed ok !)
Comment 2 Richard Henderson 2004-10-02 17:30:31 EDT
Fixed in gcc 3.3.

z.c: In function `int main()':
z.c:5: error: invalid use of template `template<class T_test_t> class

Note You need to log in before you can comment on or make changes to this bug.