public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7576: ?: used with static const member variables creates undefined reference
@ 2002-08-12  2:56 nathan
  0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-08-12  2:56 UTC (permalink / raw)
  To: edA-qa, gcc-bugs, gcc-prs, nobody

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/7576: ?: used with static const member variables creates undefined reference
@ 2002-08-12  8:06 edA-qa mort-ora-y
  0 siblings, 0 replies; 3+ messages in thread
From: edA-qa mort-ora-y @ 2002-08-12  8:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/7576; it has been noted by GNATS.

From: "edA-qa mort-ora-y" <edA-qa@disemia.com>
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.
 
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/7576: ?: used with static const member variables creates undefined reference
@ 2002-08-12  1:33 edA-qa
  0 siblings, 0 replies; 3+ messages in thread
From: edA-qa @ 2002-08-12  1:33 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7576
>Category:       c++
>Synopsis:       ?: used with static const member variables creates undefined reference
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 11 23:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     edA-qa@disemia.com
>Release:        g++ (GCC) 3.1.1 20020710 (prerelease)
>Organization:
>Environment:
cygwin, Win95 OSR2
>Description:
The attached code shows the scenario in which use of the ?: operator with const static member variables creates references to variables that ultimately the linker (ld) is not capable of finding.

The attached code demonstrates, and documents, variations that clearly isolate the ?: operator being used with const static members (note that both results have to be const static for the effect to appear).
>How-To-Repeat:
Compile the file with stand g++ options:

$> g++ gcc_test_2.cc
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gcc_test_2.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gcc_test_2.cc"

Ly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NCn0NCg0KLypDb21t
YW5kczoNCnNoZWxsPiBnKysgZ2NjX3Rlc3RfMi5jYw0KL2MvV0lORE9XUy9URU1QL2NjYVg2QThs
Lm8oLnRleHQkX1pOSzRUZXN0N0dldEl0ZW1FdisweGYpOmdjY190ZXN0XzIuY2M6IHVuZGVmaW5l
ZCByZWZlcmVuY2UgdG8gYFRlc3Q6Oml0ZW0wJw0KL2MvV0lORE9XUy9URU1QL2NjYVg2QThsLm8o
LnRleHQkX1pOSzRUZXN0N0dldEl0ZW1FdisweDE5KTpnY2NfdGVzdF8yLmNjOiB1bmRlZmluZWQg
cmVmZXJlbmNlIHRvIGBUZXN0OjppdGVtMScNCmNvbGxlY3QyOiBsZCByZXR1cm5lZCAxIGV4aXQg
c3RhdHVzDQoqLw0KDQovKlZlcnNpb246DQpnKysgKEdDQykgMy4xLjEgMjAwMjA3MTAgKHByZXJl
bGVhc2UpDQpDb3B5cmlnaHQgKEMpIDIwMDIgRnJlZSBTb2Z0d2FyZSBGb3VuZGF0aW9uLCBJbmMu
DQpUaGlzIGlzIGZyZWUgc29mdHdhcmU7IHNlZSB0aGUgc291cmNlIGZvciBjb3B5aW5nIGNvbmRp
dGlvbnMuICBUaGVyZSBpcyBOTw0Kd2FycmFudHk7IG5vdCBldmVuIGZvciBNRVJDSEFOVEFCSUxJ
VFkgb3IgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UuDQoqLw0K


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-12 11:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-12  2:56 c++/7576: ?: used with static const member variables creates undefined reference nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-08-12  8:06 edA-qa mort-ora-y
2002-08-12  1:33 edA-qa

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).