Bug 11148 - Incorrect codegen for explicit template instantiation, with ICE for error cases
Summary: Incorrect codegen for explicit template instantiation, with ICE for error cases
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.1
: P2 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on: 11149 11150
Blocks:
  Show dependency treegraph
 
Reported: 2003-06-11 03:44 UTC by M.E. O'Neill
Modified: 2003-06-12 00:15 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-06-11 04:17:07


Attachments
Test case (149 bytes, text/plain)
2003-06-11 03:46 UTC, M.E. O'Neill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description M.E. O'Neill 2003-06-11 03:44:15 UTC
The following code generates no output in GCC 3.3, and correct output for 3.2.3

--- Begin Sample Code ---------------------
template <typename X>
class Foo {
    int i;
public:
    Foo() {
#ifdef KILL_GCC_3_3
        X::explode();
#endif
    }
};

class Bar {
    Foo<int> foo_;
public:
    Bar() {}
};

template class Foo<int>;

--- End Sample Code -----------------------


If compiled with -DKILL_GCC_3_3, instead of reporting the error

buglet.cc: In constructor `Foo<X>::Foo() [with X = int]':
buglet.cc:11:   instantiated from here
buglet.cc:5: `int' is not an aggregate type

(which is what 3.2.1 does) it dies with

buglet.cc: In constructor `Foo<X>::Foo() [with X = int]':
buglet.cc:11:   instantiated from here
buglet.cc:5: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


Verified on Linux and Mac OS X.

linux% gcc -v
Reading specs from /usr/local/gcc-3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc-3.3/configure --prefix=/usr/local/gcc-3.3 --enable-languages=c,c++
Thread model: posix
gcc version 3.3

osx% gcc -v
Reading specs from /usr/local/gcc/lib/gcc-lib/powerpc-apple-darwin6.6/3.3/specs
Configured with: ../gcc-3.3/configure --prefix /usr/local/gcc --enable-languages=c,c++
Thread model: single
gcc version 3.3
Comment 1 M.E. O'Neill 2003-06-11 03:46:42 UTC
Created attachment 4198 [details]
Test case
Comment 2 M.E. O'Neill 2003-06-11 03:55:28 UTC
BTW, GCC 3.3 does produce correct output if the program is compiled with either
    -fno-implicit-templates
    -fno-exceptions

The ICE on erroneous code remains, however, so perhaps that is a separate issue?
Comment 3 Andrew Pinski 2003-06-11 04:17:07 UTC
I am split this bug up into bug 11149 and bug 11150 both are regressions.
Comment 4 Andrew Pinski 2003-06-11 22:56:56 UTC
I am closing this bug as one of the ones that was split from this is already fixed.