Article View: gnu.g++.bug
Article #226Re: data member initialization wrongly accepted
From: Mike Stump
Date: Fri, 10 Apr 1992 10:19
Date: Fri, 10 Apr 1992 10:19
42 lines
1883 bytes
1883 bytes
This is a GNU extension. All versions (probably) can flag this as an
error. Just ask it to, -ansi -pedantic to make it grip and moan about
everything under the sun.
> Date: Thu, 9 Apr 92 14:26:10 CDT
> From: dougm@cs.rice.edu (Doug Moore)
> Message-Id: <9204091926.AA03439@cs.rice.edu>
> To: bug-g++@prep.ai.mit.edu
> The following code:
> ====================
> class foo
> {
> public:
> int a = 0;
> };
> foo baz;
> ====================
> not compile under Sun C++, with the error message:
> ====================
> CC test.cc:
> "test.cc", line 2: error: initializer for member a
> 1 error
> ====================
> Looking through my C++ reference books, I cannot find anything to
> indicate what the compiler should do with an attempt to initialize a
> class data member within the class definition. Nor can I find a
> mention of this as a gnu extension in the documentation that
> accompanies gcc 2.1. Yet both g++ 1.40.3 and g++ 2.1 accept such
> initializations without complaint.
> Since my students attempt such initializations all the time and,
> worse, sometimes the initializations achieve what the student
> intended, I'd appreciate it if an upcoming version of GNU C++ flagged
> this as an error.
> BTW: The failure to warn occurs under GNU GCC 2.1, w/ Tiemann inf.
> loop patches, and patches from Mike Stump for the Sabre detected bugs,
> running on a SUN sparc2 running Sunos 4.1. The same behavior occurred
> under g++ 1.40.3.
Technical Details
Message-ID:
<9204101019.AA22670@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrsShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrs From: mrs@cygnus.com (Mike Stump) Subject: Re: data member initialization wrongly accepted Message-ID: <9204101019.AA22670@cygnus.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 10 Apr 1992 10:19:41 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 43