Bug 42655 - [4.3/4.4/4.5 Regression] ! causes the qualified types for rvalue
[4.3/4.4/4.5 Regression] ! causes the qualified types for rvalue
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.4.1
: P2 normal
: 4.3.5
Assigned To: Jason Merrill
: rejects-valid, wrong-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-01-08 03:17 UTC by Johannes Schaub
Modified: 2010-01-14 20:45 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work: 3.3
Known to fail: 4.0.0 4.1.0 4.2.0 4.3.0 4.4.0 4.5.0
Last reconfirmed: 2010-01-09 12:45:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Schaub 2010-01-08 03:17:41 UTC
GCC applies cv-qualifiers to rvalues of non-class types. The following code is all right, but GCC doesn't like it:

template<typename T>
void unused(T const &) { }

int main() {
  volatile bool x = false;
  unused(!x); // type of "!x" is bool
}
Comment 1 Andrew Pinski 2010-01-08 03:22:48 UTC
Looks like it is only an issue with ! (and bool) and not with any other expression really.
template<typename T>
void unused(T const &) { }

int main() {
  volatile int x = false;
  unused(x-0); 
}

Causes unused<int>() to be called.

Also note !!x uses volatile bool which is also wrong.
Comment 2 Andrew Pinski 2010-01-08 03:24:07 UTC
Confirmed, a regression from at least 3.3.
Comment 3 Johannes Schaub 2010-01-08 03:35:26 UTC
The following are two other cases where GCC misses to drop qualifiers

  typedef int const intt;
  unused(intt()); // intt has type 'int'

  int const f();
  unused(f()); // f() has type 'int'

Comment 4 Johannes Schaub 2010-01-08 03:40:58 UTC
(Should have mentioned i did the second set of tests with a modified "unused" having "T&" as parameter type, and relying on failure of binding of non-const references to rvalues. GCC does not reject the two calls).
Comment 5 Andrew Pinski 2010-01-08 03:42:15 UTC
(In reply to comment #3)
> The following are two other cases where GCC misses to drop qualifiers

Those two works for me. they both call unused<int> in GCC 4.4 and the trunk.  Though replace const with volatile, it fails for intt() case on the trunk and both for 4.4.  Though this is a way different issue than originally reported :).
Comment 6 Andrew Pinski 2010-01-08 03:43:03 UTC
(In reply to comment #4)
> (Should have mentioned i did the second set of tests with a modified "unused"
> having "T&" as parameter type, and relying on failure of binding of non-const
> references to rvalues. GCC does not reject the two calls).

Well the function call case has been fixed on the trunk as I mentioned in comment #5.  But these are all different issues ...
Comment 7 William K Foster 2010-01-08 03:43:23 UTC
This also fails on v3.4.6 where I first ran into it.  (I'd update the known to fail line, but I don't have permission.)
Comment 8 Jason Merrill 2010-01-14 20:22:30 UTC
Subject: Bug 42655

Author: jason
Date: Thu Jan 14 20:21:58 2010
New Revision: 155913

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155913
Log:
	PR c++/42655
	* call.c (convert_like_real): Do full decay_conversion for ck_rvalue.

Added:
    trunk/gcc/testsuite/g++.dg/overload/rvalue1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jason Merrill 2010-01-14 20:42:30 UTC
Subject: Bug 42655

Author: jason
Date: Thu Jan 14 20:42:16 2010
New Revision: 155915

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155915
Log:
	PR c++/42655
	* call.c (convert_like_real): Do full decay_conversion for ck_rvalue.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/overload/rvalue1.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/call.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 10 Jason Merrill 2010-01-14 20:45:52 UTC
Fixed in 4.4, 4.5; not fixing in 4.3.