public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this
@ 2011-05-15  3:21 zeratul976 at hotmail dot com
  2011-05-15 17:31 ` [Bug c++/49003] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zeratul976 at hotmail dot com @ 2011-05-15  3:21 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x] decltype in member function's trailing return
                    type should deduce constness of *this
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


Now that the resolution of issue #1207
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1207) made it
into the standard, the following example (taken from the same page) should
compile:

struct vector {
    struct iterator { };
    struct const_iterator { };
    iterator begin();
    const_iterator begin() const;
};
class block {
    vector v;
    auto end() const -> decltype(v.begin()) { return v.begin(); }
};

Currently, GCC gives the same error as before:

test.cpp: In member function ‘vector::iterator block::end() const’:
test.cpp:9:66: error: could not convert ‘((const
block*)this)->block::v.vector::begin()’ to ‘vector::iterator’


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

* [Bug c++/49003] [C++0x] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
@ 2011-05-15 17:31 ` redi at gcc dot gnu.org
  2011-05-16 12:15 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-15 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.15 17:19:52
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-15 17:19:52 UTC ---
I thought there was already a bug report about this but I can't find it, so
confirmed


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

* [Bug c++/49003] [C++0x] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
  2011-05-15 17:31 ` [Bug c++/49003] " redi at gcc dot gnu.org
@ 2011-05-16 12:15 ` redi at gcc dot gnu.org
  2011-05-16 15:15 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-16 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-16 11:09:05 UTC ---
ah I was thinking of PR 45908 (where I provided that reduced testcase - I knew
it looked familiar!) but that was for an ICE which is fixed, so this one should
be kept for the change in semantics


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

* [Bug c++/49003] [C++0x] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
  2011-05-15 17:31 ` [Bug c++/49003] " redi at gcc dot gnu.org
  2011-05-16 12:15 ` redi at gcc dot gnu.org
@ 2011-05-16 15:15 ` redi at gcc dot gnu.org
  2011-06-29 19:24 ` [Bug c++/49003] [C++0x][DR 1207] " jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-16 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-16 14:48:13 UTC ---
A simpler test for DR 1207 being implemented is:

struct A {
    auto a() const -> decltype(this) { return this; }
};

nc.cc:2:32: error: invalid use of 'this' at top level
nc.cc:2:32: error: invalid use of 'this' at top level

The late-specified return type should be accepted with the same type as the
return statement's expression i.e. const A*


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

* [Bug c++/49003] [C++0x][DR 1207] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
                   ` (2 preceding siblings ...)
  2011-05-16 15:15 ` redi at gcc dot gnu.org
@ 2011-06-29 19:24 ` jason at gcc dot gnu.org
  2011-06-29 21:20 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-29 19:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/49003] [C++0x][DR 1207] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
                   ` (3 preceding siblings ...)
  2011-06-29 19:24 ` [Bug c++/49003] [C++0x][DR 1207] " jason at gcc dot gnu.org
@ 2011-06-29 21:20 ` jason at gcc dot gnu.org
  2011-06-29 21:20 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-29 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-29 21:19:35 UTC ---
Author: jason
Date: Wed Jun 29 21:19:31 2011
New Revision: 175671

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175671
Log:
    DR 1207
    PR c++/49003
    * cp-tree.h (struct saved_scope): Add x_current_class_ptr,
    x_current_class_ref.
    (current_class_ptr, current_class_ref): Use them.
    * decl.c (build_this_parm): Handle getting the class type.
    * parser.c (cp_parser_late_return_type_opt): Set up 'this'
    for use within the trailing return type.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/trailing6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/pr45908.C


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

* [Bug c++/49003] [C++0x][DR 1207] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
                   ` (4 preceding siblings ...)
  2011-06-29 21:20 ` jason at gcc dot gnu.org
@ 2011-06-29 21:20 ` jason at gcc dot gnu.org
  2011-06-29 21:50 ` zeratul976 at hotmail dot com
  2011-06-29 22:21 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-29 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-29 21:20:14 UTC ---
Implemented for 4.7.


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

* [Bug c++/49003] [C++0x][DR 1207] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
                   ` (5 preceding siblings ...)
  2011-06-29 21:20 ` jason at gcc dot gnu.org
@ 2011-06-29 21:50 ` zeratul976 at hotmail dot com
  2011-06-29 22:21 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: zeratul976 at hotmail dot com @ 2011-06-29 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Nathan Ridge <zeratul976 at hotmail dot com> 2011-06-29 21:50:06 UTC ---
Thanks Jason! Is there any chance of getting this into 4.6.2?


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

* [Bug c++/49003] [C++0x][DR 1207] decltype in member function's trailing return type should deduce constness of *this
  2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
                   ` (6 preceding siblings ...)
  2011-06-29 21:50 ` zeratul976 at hotmail dot com
@ 2011-06-29 22:21 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-29 22:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-29 22:20:26 UTC ---
Created attachment 24642
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24642
patch for 4.6

I've been pretty free about applying non-regression fix patches to the 4.6
branch, but I think now that 4.6.1 has gone out I'm going to be more
conservative.  But here's a patch against the 4.6 branch if you want to apply
it locally.


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

end of thread, other threads:[~2011-06-29 22:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-15  3:21 [Bug c++/49003] New: [C++0x] decltype in member function's trailing return type should deduce constness of *this zeratul976 at hotmail dot com
2011-05-15 17:31 ` [Bug c++/49003] " redi at gcc dot gnu.org
2011-05-16 12:15 ` redi at gcc dot gnu.org
2011-05-16 15:15 ` redi at gcc dot gnu.org
2011-06-29 19:24 ` [Bug c++/49003] [C++0x][DR 1207] " jason at gcc dot gnu.org
2011-06-29 21:20 ` jason at gcc dot gnu.org
2011-06-29 21:20 ` jason at gcc dot gnu.org
2011-06-29 21:50 ` zeratul976 at hotmail dot com
2011-06-29 22:21 ` jason at gcc dot gnu.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).