From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28536 invoked by alias); 12 Aug 2002 11:36:03 -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 28522 invoked by uid 71); 12 Aug 2002 11:36:03 -0000 Date: Mon, 12 Aug 2002 08:06:00 -0000 Message-ID: <20020812113603.28521.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "edA-qa mort-ora-y" Subject: Re: c++/7576: ?: used with static const member variables creates undefined reference Reply-To: "edA-qa mort-ora-y" X-SW-Source: 2002-08/txt/msg00233.txt.bz2 List-Id: The following reply was made to PR c++/7576; it has been noted by GNATS. From: "edA-qa mort-ora-y" To: nathan@gcc.gnu.org Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/7576: ?: used with static const member variables creates undefined reference Date: Mon, 12 Aug 2002 13:29:30 +0200 I think I may actually be confused with item 9.4.2.4 of the standard. I've forgotten the out-of-class references, I'm just not convinced that they are needed (although I'm willing to accept it if this is causing more annoyance than anything more). The excerpt, "... In that case, the member can appear in integral constant expressions within its scope. The member shall still be defined in a namespace scope if it is used in the program..." I assumed that the first part indicating used in constant expressions is what is allowed the "static const" members to be used in statements like if, and array sizes, without needing the out-of-class declaration (as my example shows such cases which work). The second sentence says "if they are used", does this imply that any use of the variable requires the out-of-class definition -- in which case gcc is then (as shown in my example) compiling code which is not actually compliant (thereby allowing you to write invalid code). The example shows how I can simply replace the ?: operator with an equivalent if/else statement avert the problem. If this is not a bug then I would assume the if/else variant should also produce a compilation or linker error, as it is then not valid code. Or am I missing something? Sometime around 12 Aug 2002, nathan@gcc.gnu.org inscribed: > Synopsis: ?: used with static const member variables creates undefined reference > > State-Changed-From-To: open->closed > State-Changed-By: nathan > State-Changed-When: Mon Aug 12 01:33:30 2002 > State-Changed-Why: > not a bug. You have not included an out-of-class > definition of your static members. See [9.4.2]/4 > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7576 -- edA-qa mort-ora-y I know the truth is a myth, but that doesn't mean I'll stop searching for it.