public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8797: g++ accepts in-class initialization of non-integral static member
@ 2002-12-03 7:46 bangerth
0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-12-03 7:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 8797
>Category: c++
>Synopsis: g++ accepts in-class initialization of non-integral static member
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Tue Dec 03 07:46:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
2.95 through 3.3CVS, Linux (but front end matter anyway)
>Description:
Based on the discussion on PR 8778 (to be found in the audit
trail of that report):
gcc accepts this although the standard says that only
integral _scalars_ can be initialized in-class:
-----------------------------
struct A {
static const int i[] = { 1,2 };
};
-----------------------------
I _do_ get a warning if I use -pedantic. However, I maintain
that I should get an unconditional _error_ instead.
On the other hand, if this is a gcc extension, it should
- be documented in the manual
- generate an _error_ on -pedantic -ansi
To make things a little worse: templatizing the class like
---------------------------------------
template <int> struct A {
static const int i[] = { 1,2 };
};
template struct A<1>;
---------------------------------------
yields the following, slightly convoluted error message
stating the same content twice in different words:
tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -pedantic -ansi -c x.cc
x.cc:2: warning: ISO C++ forbids initialization of member constant `i' of
non-integral type `const int[]'
x.cc: In instantiation of `A<1>':
x.cc:5: instantiated from here
x.cc:2: warning: ISO C++ forbids initialization of member constant `A<1>::i' of
non-integral type `const int[2]'
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/8797: g++ accepts in-class initialization of non-integral static member
@ 2003-01-13 23:26 reichelt
0 siblings, 0 replies; 2+ messages in thread
From: reichelt @ 2003-01-13 23:26 UTC (permalink / raw)
To: bangerth, gcc-bugs, gcc-prs, nobody
Synopsis: g++ accepts in-class initialization of non-integral static member
State-Changed-From-To: open->closed
State-Changed-By: reichelt
State-Changed-When: Mon Jan 13 15:26:30 2003
State-Changed-Why:
Fixed with the new parser.
We now get the following error message (even without -pedantic):
bug.cc:2: error: a brace-enclosed initializer is not allowed here
bug.cc:2: error: invalid in-class initialization of static data member of
non-integral type `const int[]'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8797
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-13 23:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-03 7:46 c++/8797: g++ accepts in-class initialization of non-integral static member bangerth
2003-01-13 23:26 reichelt
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).