public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: stephen.hill@motorola.com To: gcc-gnats@gcc.gnu.org Subject: c++/6507: auto type promotion of referee in reference member variable initialization Date: Mon, 29 Apr 2002 08:16:00 -0000 [thread overview] Message-ID: <20020429151510.4156.qmail@sources.redhat.com> (raw) >Number: 6507 >Category: c++ >Synopsis: auto type promotion of referee in reference member variable initialization >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Mon Apr 29 08:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: stephen.hill@motorola.com >Release: gcc 2.95.2 19991024 (release) >Organization: >Environment: Linux x86 (suse 7.0 default install) >Description: Note: I'm not sure if this really is a bug (or just a feature), but it strikes me that the code is doing something so different from a reasonable expectation that a closer examination of the reasoning might be desirable. When initializing a reference member variable of a class, it appears that gcc attempts do do a type promotion of the referee into the reference class, then references the promoted variable. In the attached code, note the difference between reference and referee addresses.If the constructor (lines 19-22) is replaced by a constructor which does not take an argument of the reference type (lines 24-27) an error is generated. This makes me believe that automatic type promotion is involved. Note that if b (line 38) is declared as const explicit Foo &b; rather than const Foo &b then no problem results. Thanks, steve >How-To-Repeat: compile attached file (gcc -o bug_test bug_test.cc) run (./bug_test) >Fix: Assume that member references to member variables are explicit or warn? >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-04-29 15:16 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-29 8:16 stephen.hill [this message] 2002-06-05 8:26 lerdsuwa 2003-01-14 22:58 bangerth 2003-01-17 14:46 Hill Stephen-STEHILL1 2003-01-17 14:47 paolo 2003-01-23 1:45 bangerth
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=20020429151510.4156.qmail@sources.redhat.com \ --to=stephen.hill@motorola.com \ --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: linkBe 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).