public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17323] New: ICE on invalid code if static member array initialized with size computed as division by zero
@ 2004-09-04 18:55 niemayer at isg dot de
  2004-09-04 18:56 ` [Bug c++/17323] " niemayer at isg dot de
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: niemayer at isg dot de @ 2004-09-04 18:55 UTC (permalink / raw)
  To: gcc-bugs

The following tiny piece of C++ code causes an ICE:

---------------------- ice.cxx --------------------------------------
template <class T>
class A {
	static const int x = 1024/sizeof(T);	
	static char i[x];
};

class B : public A<B> { };
-------------------------------------------------------------------

Output after "gcc -c ice.cxx" is:
ice.cxx: In instantiation of `A<B>':
ice.cxx:8:   instantiated from here
ice.cxx:4: error: invalid application of `sizeof' to incomplete type `B' 
ice.cxx:4: warning: division by zero in `1024 / 0'
gcc: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.


BTW: I would be very interested to hear if there's a legal (compile-time)
equivalent to the code above - so far I've found only clumsy work-arounds that
need run-time tests.

-- 
           Summary: ICE on invalid code if static member array initialized
                    with size computed as division by zero
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: niemayer at isg dot de
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-06-14  8:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-04 18:55 [Bug c++/17323] New: ICE on invalid code if static member array initialized with size computed as division by zero niemayer at isg dot de
2004-09-04 18:56 ` [Bug c++/17323] " niemayer at isg dot de
2004-09-06 16:13 ` lerdsuwa at gcc dot gnu dot org
2004-09-06 16:56 ` giovannibajo at libero dot it
2004-09-07 23:53 ` bangerth at dealii dot org
2004-09-08  7:04 ` pinskia at gcc dot gnu dot org
2005-02-10 20:32 ` [Bug c++/17323] [3.4/4.0 regression] " reichelt at gcc dot gnu dot org
2005-05-19 17:36 ` [Bug c++/17323] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
2005-06-14  8:31 ` reichelt at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).