public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: dohashi@floccinaucinihilipilification.net
To: gcc-gnats@gcc.gnu.org
Subject: c++/9683: bug in initialization chains for static const variables from template classes
Date: Thu, 13 Feb 2003 02:46:00 -0000	[thread overview]
Message-ID: <20030213024207.1470.qmail@sources.redhat.com> (raw)


>Number:         9683
>Category:       c++
>Synopsis:       bug in initialization chains for static const variables from template classes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 13 02:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Darin Ohashi
>Release:        3.2.1
>Organization:
>Environment:
slackware-current
Configured with: ../gcc-3.2.1/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i386-slackware-linux --host=i386-slackware-linux
Thread model: posix
gcc version 3.2.1
>Description:

Initialization chains of static const variables in templates does not work properly.  If a variable is initialized by a chain of two variables, neither of which is referenced, then the intialization does not occur.

template <class data> const int foo<data>::a = 1;
template <class data> const int foo<data>::b = a;
template <class data> const int foo<data>::c = b;
template <class data> const int foo<data>::d = c;

c and d will not be initialized properly if a and b are not used.  If a is used, c will be initiailized, but d will not be. 
>How-To-Repeat:
hades:~/project/gcc-bug> g++ bug1.cc       
hades:~/project/gcc-bug> ./a.out     
0
0
hades:~/project/gcc-bug> g++ -DA_C bug1.cc 
hades:~/project/gcc-bug> ./a.out           
1
1
hades:~/project/gcc-bug> g++ -DA_D bug1.cc 
hades:~/project/gcc-bug> ./a.out           
1
0
>Fix:

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

CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnRlbXBsYXRlIDxjbGFzcyBkYXRhPiBjbGFzcyBmb28Kewog
ICAgcHVibGljOgoJc3RhdGljIGNvbnN0IGludCBhOwoJc3RhdGljIGNvbnN0IGludCBiOwoJc3Rh
dGljIGNvbnN0IGludCBjOwoJc3RhdGljIGNvbnN0IGludCBkOwp9OwoKdGVtcGxhdGUgPGNsYXNz
IGRhdGE+IGNvbnN0IGludCBmb288ZGF0YT46OmEgPSAxOwp0ZW1wbGF0ZSA8Y2xhc3MgZGF0YT4g
Y29uc3QgaW50IGZvbzxkYXRhPjo6YiA9IGE7CnRlbXBsYXRlIDxjbGFzcyBkYXRhPiBjb25zdCBp
bnQgZm9vPGRhdGE+OjpjID0gYjsKdGVtcGxhdGUgPGNsYXNzIGRhdGE+IGNvbnN0IGludCBmb288
ZGF0YT46OmQgPSBjOwoKdHlwZWRlZiBmb288aW50PiBmb29JbnQ7CgppbnQgbWFpbiggdm9pZCAp
CnsKICAgIGZvb0ludCAqZjsKCiAgICBmID0gbmV3IGZvb0ludCgpOwoKI2lmIGRlZmluZWQgQV9D
CiAgICBzdGQ6OmNvdXQgPDwgZi0+YSA8PCAiXG4iOwogICAgc3RkOjpjb3V0IDw8IGYtPmMgPDwg
IlxuIjsKI2VsaWYgZGVmaW5lZCBBX0QKICAgIHN0ZDo6Y291dCA8PCBmLT5hIDw8ICJcbiI7CiAg
ICBzdGQ6OmNvdXQgPDwgZi0+ZCA8PCAiXG4iOwojZWxzZQogICAgc3RkOjpjb3V0IDw8IGYtPmMg
PDwgIlxuIjsKICAgIHN0ZDo6Y291dCA8PCBmLT5kIDw8ICJcbiI7CiNlbmRpZgp9Cg==


                 reply	other threads:[~2003-02-13  2:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030213024207.1470.qmail@sources.redhat.com \
    --to=dohashi@floccinaucinihilipilification.net \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).