public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Hill Stephen-STEHILL1 <Stephen.Hill@motorola.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/6507: auto type promotion of referee in reference member variable initialization Date: Fri, 17 Jan 2003 14:46:00 -0000 [thread overview] Message-ID: <20030117144605.23535.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/6507; it has been noted by GNATS. From: Hill Stephen-STEHILL1 <Stephen.Hill@motorola.com> To: Hill Stephen-STEHILL1 <Stephen.Hill@motorola.com>, "'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>, "'gcc-prs@gcc.gnu.org'" <gcc-prs@gcc.gnu.org>, "'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>, "'nobody@gcc.gnu.org'" <nobody@gcc.gnu.org> Cc: Subject: Re: c++/6507: auto type promotion of referee in reference member variable initialization Date: Fri, 17 Jan 2003 14:41:56 -0000 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C2BE36.95877D52 Content-Type: text/plain; charset="iso-8859-1" Apologies, I had some email issues which led to my mail of the testcase (attached) being bounced. This got missed in the email deluge on my return from a holiday. So here is the testcase again. Thanks Steve <<bug_test.cc>> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p r=6507 ------_=_NextPart_000_01C2BE36.95877D52 Content-Type: application/octet-stream; name="bug_test.cc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bug_test.cc" /* gcc version 3.1 configured with configure --enable-threads = --with-cpu=3Di686 first discovered on g++ version 2.95.2 19991024 (release)=20 =09 bug_test - steve hill 29/04/02. email: stephen.hill@motorola.com =09 a,b are constant references to private member variables p_a,p_b. If we = get the class wrong on p_b (line 52), then b and p_b are of different = classes but the compiler does not issue a warning or error, and makes p_b = refer to a different address than the one we intend - probably because = the automatic=20 type promotion is invoked. No warning is issued that auto type = promotion (or whatever) has changed the address of the referee. */ #include <iostream> using namespace std; typedef unsigned short int ID; class Foo { int i; =09 public: Foo(int j) //no bug if this is declared as explicit :i(j) {}; =09 /* //Issues a compile error if this is included because auto type = promotion is not now possible Foo() :i(0) {};=20 */ ~Foo() {}; }; class bug_test { public: const ID &a; const Foo &b; =20 =09 bug_test() :a(p_a),b(p_b),p_a(1),p_b(2) { cerr<<"Reference addresses:\t" << &a << " " << &b << "\n"; cerr<<"Referee addresses:\t"<<&p_a << " " << &p_b << "\n"; }; ~bug_test() {}; =09 private: ID p_a; ID p_b; // !! should be declared as a Foo !! =09 }; int main() { bug_test b; return 0; } ------_=_NextPart_000_01C2BE36.95877D52--
next reply other threads:[~2003-01-17 14:46 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-01-17 14:46 Hill Stephen-STEHILL1 [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-01-23 1:45 bangerth 2003-01-17 14:47 paolo 2003-01-14 22:58 bangerth 2002-06-05 8:26 lerdsuwa 2002-04-29 8:16 stephen.hill
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=20030117144605.23535.qmail@sources.redhat.com \ --to=stephen.hill@motorola.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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).