public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Giovanni Bajo" <giovannibajo@libero.it> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/9103: problems constructing from temporaries Date: Fri, 24 Jan 2003 16:16:00 -0000 [thread overview] Message-ID: <20030124161601.4931.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/9103; it has been noted by GNATS. From: "Giovanni Bajo" <giovannibajo@libero.it> To: <gcc-gnats@gcc.gnu.org>, <darryl.green@unitab.com.au>, <gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org>, <gcc-prs@gcc.gnu.org> Cc: Subject: Re: c++/9103: problems constructing from temporaries Date: Fri, 24 Jan 2003 17:11:38 +0100 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p r=9103 Epurated test case: ----------------------- struct A { A(const A& ) {} A(A* ) {} A( ) {} void foo(void); }; int main() { A a(A(A(new A()))); a.foo(); } ----------------------- ice7.cpp: In function `int main()': ice7.cpp:116: request for member `foo' in `a()', which is of non-aggregate type `A ()()' This is on GCC 3.2. The above should clearly compile, since the line cannot be a function declaration (because of the 'new' in it). GCC seems to be confused because of the two temporaries, and you can see that also the dumped type is wrong. If you remove one temporary: A a(A(new A())); the code compiles correctly. If you remove the 'new': A a(A(A(A()))); the code fails as expected, but the error shows there is still some confusion: ice7.cpp:116: request for member `foo' in `a(A (*)(A (*)()))', which is of non-aggregate type `A ()(A (*)(A (*)()))' since it's missing the third function pointer (should be `A ()(A (*)(A (*)(A (*)())))'. For the original poster, I'd suggest using the alternative syntax A a = A(whatever), unless the constructors are explicit. Giovanni Bajo
next reply other threads:[~2003-01-24 16:16 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-01-24 16:16 Giovanni Bajo [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-04-07 14:04 bangerth 2003-04-07 11:06 Giovanni Bajo 2003-01-24 16:27 bangerth 2002-12-31 11:46 Andrew Pinski 2002-12-30 18:56 Darryl Green 2002-12-29 21:46 darryl.green
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=20030124161601.4931.qmail@sources.redhat.com \ --to=giovannibajo@libero.it \ --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).