From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4321 invoked by alias); 16 Oct 2005 19:53:10 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 4306 invoked by uid 22791); 16 Oct 2005 19:53:07 -0000 Received: from sccimhc91.asp.att.net (HELO sccimhc91.asp.att.net) (63.240.76.165) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 16 Oct 2005 19:53:07 +0000 Received: from xaivrxp (12-210-217-111.client.insightbb.com[12.210.217.111]) by sccimhc91.asp.att.net (sccimhc91) with SMTP id <20051016195305i91001de8ke>; Sun, 16 Oct 2005 19:53:05 +0000 From: "John Ratliff" To: Subject: RE: C++ static integer class constants... Date: Sun, 16 Oct 2005 19:53:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <20051016193043.GA28380@hymen> X-SW-Source: 2005-10/txt/msg00090.txt.bz2 Message-ID: <20051016195300.scjkX1oXpa1vXhIhMVjQTlPFkxCCyrvaSEOQLjyit3s@z> > On Sun, Oct 16, 2005 at 02:02:09PM -0500, John Ratliff wrote: > > This seems like a definite bug. The fact that it works in 3.4.2 and not > in > > 3.3.3 seems like a probable bug to me, but I will ask this question in a > > standard C++ newsgroup so that someone intimately familiar with the > standard > > can give me a definitive answer, but I still think g++ 3.3 is wrong and > g++ > > 3.4 is right. > > > > If I were taking the address of the constant, sure, it would have to > have > > storage space and I wouldn't expect it any other way. > > > > I agree in that this is a weird behaviour, but I don't think it's > exactly a bug, unless it is mandatory for a compiler to try > everything possible before taking the address of a constant. Maybe > GCC 3.3 simply couldn't find a way to use the constants directly. On comp.lang.c++, Victor Bazarov says my example program is well-formed standard C++ according to the ISO C++ standard. "Since their address is never taken, the 'foo::A' and 'foo::B' are, in fact, compile-time constant expressions that do not require storage. The objects, therefore, don't need to be defined outside of the class definition. g++ 3.3.3 is probably too old. It's even too old and non- compliant in this particular case even with 1998 version of the C++ Standard. The standard was amended to allow const statics to be only defined in the class definition if their address is not taken _even_ if they are "used" outside the class. [I am too lazy, though, to look it up in the Standard...]" -- Victor Bazarov (comp.lang.c++) I am going to upgrade to g++ 3.4, but I think it is a g++ 3.3.3 and 3.3.5 bug. I should go see if 3.3.6 fixed this. Thanks, --John Ratliff