public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36628] New: incorrect declspec() handling of conditional operator
@ 2008-06-25 8:37 abarbati at iaanus dot com
2008-06-25 9:16 ` [Bug c++/36628] [c++0x] incorrect decltype() " paolo dot carlini at oracle dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: abarbati at iaanus dot com @ 2008-06-25 8:37 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
@ 2008-06-25 9:16 ` paolo dot carlini at oracle dot com
2008-06-26 11:39 ` abarbati at iaanus dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-06-25 9:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from paolo dot carlini at oracle dot com 2008-06-25 09:15 -------
You mean decltype, right? And I would guess you stumbled on the issue while
implementing common_type... Let's CC Doug, the main author of the code.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |doug dot gregor at gmail dot
| |com
Summary|incorrect declspec() |[c++0x] incorrect decltype()
|handling of conditional |handling of conditional
|operator |operator
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
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
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: abarbati at iaanus dot com @ 2008-06-26 11:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from abarbati at iaanus dot com 2008-06-26 11:39 -------
After a more careful reading of 5/5, 5.16/4 and 7.1.6.2/4, I believe that gcc
is correctly handling the int& case, that is the expected output should be:
FivE
FRivE
FivE
Only the int&& case is thus incorrect, according to my interpretation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dgregor at gcc dot gnu dot org @ 2008-07-07 23:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dgregor at gcc dot gnu dot org 2008-07-07 23:28 -------
The problem here is that fold() is simplifying the expression before we look at
its type. The simplification here turns something that's not a function call (a
conditional expression) into a function call, thereby triggering a different
branch in the decltype code (which returns the return type of a function being
called).
--
dgregor at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dgregor at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-07-07 23:28:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
` (2 preceding siblings ...)
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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-12-02 17:52 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|dgregor at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-07-12 21:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jason at gcc dot gnu dot org 2009-07-12 21:10 -------
Subject: Bug 36628
Author: jason
Date: Sun Jul 12 21:10:09 2009
New Revision: 149536
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149536
Log:
PR c++/36628
* tree.c (rvalue): Use lvalue_or_rvalue_with_address_p.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/decltype17.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/tree.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
` (4 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-07-13 6:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2009-07-13 06:06 -------
Subject: Bug 36628
Author: jason
Date: Mon Jul 13 06:06:27 2009
New Revision: 149543
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149543
Log:
PR c++/36628
* tree.c (rvalue): Use lvalue_or_rvalue_with_address_p.
PR c++/37206
* cp-tree.h (enum cp_lvalue_kind_flags): Add clk_rvalueref.
* tree.c (lvalue_p_1): Return it. Remove
treat_class_rvalues_as_lvalues parm.
(real_lvalue_p): Disallow pseudo-lvalues here.
(lvalue_or_rvalue_with_address_p): New fn.
* call.c (initialize_reference): Use it instead of real_lvalue_p.
PR c++/40689
* init.c (build_new_1): Handle initializer list as array initializer.
(build_vec_init): Likewise.
* typeck.c (cp_build_modify_expr): Likewise.
* typeck2.c (process_init_constructor_array): Error rather than abort
if too many initializers.
Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype17.C
- copied unchanged from r149536,
trunk/gcc/testsuite/g++.dg/cpp0x/decltype17.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/initlist20.C
- copied unchanged from r149534,
trunk/gcc/testsuite/g++.dg/cpp0x/initlist20.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/initlist21.C
- copied unchanged from r149534,
trunk/gcc/testsuite/g++.dg/cpp0x/initlist21.C
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/rv10.C
- copied unchanged from r149534, trunk/gcc/testsuite/g++.dg/cpp0x/rv10.C
Modified:
branches/gcc-4_4-branch/gcc/cp/ChangeLog
branches/gcc-4_4-branch/gcc/cp/ChangeLog-2007 (props changed)
branches/gcc-4_4-branch/gcc/cp/ChangeLog-2008 (props changed)
branches/gcc-4_4-branch/gcc/cp/call.c
branches/gcc-4_4-branch/gcc/cp/cp-tree.h
branches/gcc-4_4-branch/gcc/cp/init.c
branches/gcc-4_4-branch/gcc/cp/tree.c
branches/gcc-4_4-branch/gcc/cp/typeck.c
branches/gcc-4_4-branch/gcc/cp/typeck2.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog-2008 (props changed)
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ (props changed)
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C
(props changed)
branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr36227.c (props
changed)
branches/gcc-4_4-branch/gcc/testsuite/gcc.target/x86_64/abi/callabi/
(props changed)
Propchange: branches/gcc-4_4-branch/gcc/cp/ChangeLog-2007
('svn:mergeinfo' modified)
Propchange: branches/gcc-4_4-branch/gcc/cp/ChangeLog-2008
('svn:mergeinfo' modified)
Propchange: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog-2008
('svn:mergeinfo' modified)
Propchange: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/
('svn:mergeinfo' modified)
Propchange: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C
('svn:mergeinfo' modified)
Propchange: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr36227.c
('svn:mergeinfo' modified)
Propchange:
branches/gcc-4_4-branch/gcc/testsuite/gcc.target/x86_64/abi/callabi/
('svn:mergeinfo' modified)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/36628] [c++0x] incorrect decltype() handling of conditional operator
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
` (5 preceding siblings ...)
2009-07-13 6:07 ` jason at gcc dot gnu dot org
@ 2009-07-14 5:17 ` jason at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-07-14 5:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jason at gcc dot gnu dot org 2009-07-14 05:17 -------
Fixed for 4.4.1.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36628
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-07-14 5:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-25 8:37 [Bug c++/36628] New: incorrect declspec() handling of conditional operator abarbati at iaanus dot com
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
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).