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

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 ` paolo.carlini at oracle dot com
2012-05-03 23:21 ` luto at mit dot edu
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).