From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4553 invoked by alias); 16 Mar 2003 09:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4533 invoked by uid 71); 16 Mar 2003 09:36:01 -0000 Date: Sun, 16 Mar 2003 09:36:00 -0000 Message-ID: <20030316093601.4504.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Gabriel Dos Reis Subject: Re: c++/10086: static const int unresolved in ? : construct Reply-To: Gabriel Dos Reis X-SW-Source: 2003-03/txt/msg01052.txt.bz2 List-Id: The following reply was made to PR c++/10086; it has been noted by GNATS. From: Gabriel Dos Reis To: "Giovanni Bajo" Cc: , , Subject: Re: c++/10086: static const int unresolved in ? : construct Date: 16 Mar 2003 10:28:29 +0100 "Giovanni Bajo" writes: | http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p | r=10086 I think arguments can be made for both sides (bug or not a bug) in this particular case. Certainly understand what is going on involves understanding how the compiler is treating internal the expression v ? A : B Certainly, it is not an integrable constant expression and it is an lvalue. Wihch means the compiler is internally taking the address of both Base::A and Base::B. Hence the link error. | I'm not sure what it is going on. I know that the standard says that you | still have to define an initialized static const member (even if there is an | open defect report about this, I believe). But then, why this should work: | | struct Foo | { | static const int A = 0; | }; | | int main(void) | { | return Foo::A; | } | | This one compiles and links correctly on G++ 3.2, but it should not. In the above, Foo::A is used in a such way that its definition isn't needed, i.e. its address isn't taken. I agree with you that all that is confusing. A reason why I've always thought of that as a misfeature -- it doesn't scale easily. -- Gaby