public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates
@ 2012-05-03 23:09 luto at mit dot edu
  2012-05-03 23:12 ` [Bug c++/53223] " paolo.carlini at oracle dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: luto at mit dot edu @ 2012-05-03 23:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

             Bug #: 53223
           Summary: [c++0x] auto&& and operator* don't mix inside
                    templates
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: luto@mit.edu


This is truly bizarre:

struct A
{
  int good() const;
  int operator *() const;
};

template<typename T>
void func(T t)
{
  A x;
  auto &&g1 = x.good();       // OK
  auto &&g2 = x.operator*();  // OK
  auto &&error = *x;          // error here
}

void func2(int)
{
  A x;
  auto &&g = *x;              // OK
}

int main()
{
  func(0);
  func2(0);
}

gcc 4.6 and 4.7 can't compile the line marked "error here".  The error looks
like:

auto-rvalue.cc: In instantiation of ‘void func(T) [with T = int]’:
auto-rvalue.cc:24:9:   required from here
auto-rvalue.cc:13:19: error: invalid initialization of non-const reference of
type ‘int&’ from an rvalue of type ‘int’

I suppose this could be correct, but I'd be very surprised.  clang++ 2.9
accepts this code.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
@ 2012-05-03 23:12 ` paolo.carlini at oracle dot com
  2012-05-03 23:21 ` luto at mit dot edu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-03 23:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-03 23:12:34 UTC ---
Don't we have something in Bugzilla about auto && ?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
  2012-05-03 23:12 ` [Bug c++/53223] " paolo.carlini at oracle dot com
  2012-05-03 23:21 ` luto at mit dot edu
@ 2012-05-03 23:21 ` paolo.carlini at oracle dot com
  2012-05-03 23:26 ` luto at mit dot edu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-03 23:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-03 23:21:28 UTC ---
I meant PR50473, may or may not be related.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
  2012-05-03 23:12 ` [Bug c++/53223] " paolo.carlini at oracle dot com
@ 2012-05-03 23:21 ` luto at mit dot edu
  2012-05-03 23:21 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: luto at mit dot edu @ 2012-05-03 23:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #2 from Andy Lutomirski <luto at mit dot edu> 2012-05-03 23:21:10 UTC ---
(In reply to comment #1)
> Don't we have something in Bugzilla about auto && ?

There's PR 52851, but that's supposedly fixed in 4_7-branch, and (unless I
messed up) this bug is present in 4_7-branch updated today (r187118).  The test
case from that bug works on my compiler.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
                   ` (2 preceding siblings ...)
  2012-05-03 23:21 ` paolo.carlini at oracle dot com
@ 2012-05-03 23:26 ` luto at mit dot edu
  2012-05-03 23:29 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: luto at mit dot edu @ 2012-05-03 23:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #4 from Andy Lutomirski <luto at mit dot edu> 2012-05-03 23:25:54 UTC ---
PR51547 could be the same thing.  I'll build and test trunk.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
                   ` (3 preceding siblings ...)
  2012-05-03 23:26 ` luto at mit dot edu
@ 2012-05-03 23:29 ` paolo.carlini at oracle dot com
  2012-05-03 23:58 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-03 23:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-03
     Ever Confirmed|0                           |1

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-03 23:29:17 UTC ---
Any further information is welcome, but for sure trunk rejects this, like 4.7.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
                   ` (4 preceding siblings ...)
  2012-05-03 23:29 ` paolo.carlini at oracle dot com
@ 2012-05-03 23:58 ` paolo.carlini at oracle dot com
  2012-05-04  0:02 ` paolo.carlini at oracle dot com
  2012-05-04  0:05 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-03 23:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-03 23:57:59 UTC ---
If we compare lines #12 and #13, there are subtle differences inside
reference_binding (called by initialize_reference, which produces the error):
for line #12, which is accepted, TYPE_REF_IS_RVALUE (rto) is true; for line #13
is false (thus reference_binding early returns NULL, no success)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
                   ` (5 preceding siblings ...)
  2012-05-03 23:58 ` paolo.carlini at oracle dot com
@ 2012-05-04  0:02 ` paolo.carlini at oracle dot com
  2012-05-04  0:05 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-04  0:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-04 00:02:29 UTC ---
In short, the first argument of initialize_reference itself, the type of the
expression to be converted, has TYPE_REF_IS_RVALUE true for #12 and false for
#13, which should be equivalent.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/53223] [c++0x] auto&& and operator* don't mix inside templates
  2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
                   ` (6 preceding siblings ...)
  2012-05-04  0:02 ` paolo.carlini at oracle dot com
@ 2012-05-04  0:05 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-04  0:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53223

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-04 00:05:15 UTC ---
Sorry, the first argument is the reference type to which the expression is
converted.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-04  0:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-03 23:09 [Bug c++/53223] New: [c++0x] auto&& and operator* don't mix inside templates luto at mit dot edu
2012-05-03 23:12 ` [Bug c++/53223] " paolo.carlini at oracle dot com
2012-05-03 23:21 ` luto at mit dot edu
2012-05-03 23:21 ` paolo.carlini at oracle dot com
2012-05-03 23:26 ` luto at mit dot edu
2012-05-03 23:29 ` paolo.carlini at oracle dot com
2012-05-03 23:58 ` paolo.carlini at oracle dot com
2012-05-04  0:02 ` paolo.carlini at oracle dot com
2012-05-04  0:05 ` paolo.carlini at oracle dot com

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).