Bug 15038 - [3.4/4.0 Regression] ICE on template instantiation
Summary: [3.4/4.0 Regression] ICE on template instantiation
Status: RESOLVED DUPLICATE of bug 15165
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-04-21 10:23 UTC by peter
Modified: 2004-10-30 21:11 UTC (History)
1 user (show)

See Also:
Host: i686-linux-gnu
Target: i686-linux-gnu
Build: u686-linux-gnu
Known to work: 3.3.4
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-04-21 11:34:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description peter 2004-04-21 10:23:20 UTC
GCC 3.4.0 release, bootstrapped native compiler for x86 linux. (Also happens
with i686-linux cross-compiler to xscale-elf.)

The authors of the code probably meant to declare the ByteCount constructor
"explicit", but it shouldn't ICE just because they didn't.

This is a regression from both GCC 2.95.3 and 3.3.2 -- they both compile this fine.

Full compiler version:
----
Reading specs from /home/peter/gcc3temp/lib/gcc/i686-empeg-linux/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --build=i686-empeg-linux
--target=i686-empeg-linux --host=i686-empeg-linux --prefix=/home/peter/gcc3temp
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.0
----

Compiler output:
----
vismgr.cpp: In member function `bool Visual::DrawsAllPixels() const':
vismgr.cpp:30: internal compiler error: in instantiate_template, at cp/pt.c:8668
Please submit a full bug report,
with preprocessed source if appropriate.
----

Preprocessed file:
----
# 1 "vismgr.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "vismgr.cpp"
typedef long long LONGLONG;

class ByteCount
{
public:
    typedef LONGLONG BaseType;
    BaseType m_bytes;

    template<typename T>
    inline ByteCount( T bytes ) :
        m_bytes( static_cast<BaseType>(bytes) )
    {
    }


    friend bool operator!=( const ByteCount &x, const ByteCount &y );
};

class Visual
{
public:
    int m_render_type;
    bool m_fullscreen;
    enum { Render_transparent = 1,
    Render_opaque,
    Render_modify,
           Render_16bit};
    bool DrawsAllPixels() const
    {
 return m_fullscreen && (m_render_type != Render_modify);
    }
};
----
Comment 1 Andrew Pinski 2004-04-21 11:34:06 UTC
Confirmed, reduced to:
struct y
{
    template<typename T>
    inline y( T bytes )
    {}
};
bool operator!=( const y &x, const y &y );
enum {
 Render_modify
};
int m_render_type;
void t()
{
  (m_render_type != Render_modify);
}
Comment 2 Wolfgang Bangerth 2004-04-21 14:11:49 UTC
Indeed: 
--------------- 
struct S { 
    template<typename T> inline S(T) {} 
}; 
bool operator!= (const S &x, const S &S); 
 
struct {} e; 
bool x= (e != e); 
--------------- 
 
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc:7: internal compiler error: in instantiate_template, at cp/pt.c:8676 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc:6: error: non-local variable `<anonymous struct> e' uses anonymous type 
x.cc:7: internal compiler error: in instantiate_template, at cp/pt.c:8679 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
Comment 3 Mark Mitchell 2004-05-23 23:04:05 UTC

*** This bug has been marked as a duplicate of 15165 ***