public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "abarbati at iaanus dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/36628] New: incorrect declspec() handling of conditional operator Date: Wed, 25 Jun 2008 08:37:00 -0000 [thread overview] Message-ID: <bug-36628-16380@http.gcc.gnu.org/bugzilla/> (raw) I compiled the following code with gcc 4.3.0 mingw (more details at the end of the report) with: g++ -std=c++0x test.cpp ---- #include <iostream> #include <typeinfo> int rvalue(); int& lvalueref(); int&& rvalueref(); decltype(true ? rvalue() : rvalue()) f() {} decltype(true ? lvalueref() : lvalueref()) g() {} decltype(true ? rvalueref() : rvalueref()) h() {} int main() { std::cout << typeid(f).name() << "\n"; std::cout << typeid(g).name() << "\n"; std::cout << typeid(h).name() << "\n"; } ----- The output is: FivE FRivE FOivE this suggests that declspec() was interpreted respectively as int, int& and int&&. However a careful reading of clause 5, paragraph 5 and 6, makes it clear that the result should have been int in all three cases, so correct output should have been: FivE FivE FivE The fact is that, when evaluating the type of the arguments of the conditional operator, int& and int&& should be adjusted to int "prior to any further analysis". Once both the second and third parameters are adjusted to int, the conditional operator can't help returning an int (5.16/6). To be precise, the results are an lvalue of type int and rvalue of type int, respectively, but that is very different from saying that they are int& and int&& and declspec should be aware of that. Additional compiler info: $ g++ -v Using built-in specs. Target: mingw32 Configured with: ../gcc-4.3.0/configure --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-concept-checks --enable-version-specific-runtime-libs --build=mingw32 --with-bugurl=http://www.mingw.org/bugs.shtml --prefix=/mingw --with-gmp=/mingw/src/gcc/gmp-mpfr-root --with-mpfr=/mingw/src/gcc/gmp-mpfr-root --with-libiconv-prefix=/mingw/src/gcc/libiconv-root Thread model: win32 gcc version 4.3.0 20080305 (alpha-testing) mingw-20080502 (GCC) -- Summary: incorrect declspec() handling of conditional operator Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: abarbati at iaanus dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
next reply other threads:[~2008-06-25 8:37 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-06-25 8:37 abarbati at iaanus dot com [this message] 2008-06-25 9:16 ` [Bug c++/36628] [c++0x] incorrect decltype() " paolo dot carlini at oracle dot com 2008-06-26 11:39 ` abarbati at iaanus dot com 2008-07-07 23:28 ` dgregor at gcc dot gnu dot org 2008-12-02 17:52 ` jason at gcc dot gnu dot org 2009-07-12 21:10 ` jason at gcc dot gnu dot org 2009-07-13 6:07 ` jason at gcc dot gnu dot org 2009-07-14 5:17 ` jason at gcc dot gnu dot org
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=bug-36628-16380@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).