public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54849] New: Override specifier with trailing return type
@ 2012-10-07 17:42 ashish.sadanandan at gmail dot com
  2012-10-07 18:02 ` [Bug c++/54849] " daniel.kruegler at googlemail dot com
  2012-10-07 18:05 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: ashish.sadanandan at gmail dot com @ 2012-10-07 17:42 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54849
           Summary: Override specifier with trailing return type
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ashish.sadanandan@gmail.com


struct Base
{
  virtual auto f () const -> int = 0;
};

struct Derived : public Base
{
  virtual auto f () const -> int override { return 0; }
};

int main() { Derived d; }

The above fails to compile. Errors:

error: expected ';' at end of member declaration
error: 'override' does not name a type

Both errors are reported for the definition of Derived::f. According to the
standard, section 8.4.1 Function definitions have the form

function-definition:
attribute-specifier-seqopt decl-specifier-seqopt declarator
virt-specifier-seqopt function-body

The declarator in a function-definition shall have the form
  D1 ( parameter-declaration-clause ) cv-qualifier-seqopt
    ref-qualifieropt exception-specificationopt attribute-specifier-seqopt
trailing-return-typeopt

Since the declarator includes the trailing return type, I believe the above
should compile.

If the override specifier is moved before the -> the code does compile, but
that doesn't jive with the standard.


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

* [Bug c++/54849] Override specifier with trailing return type
  2012-10-07 17:42 [Bug c++/54849] New: Override specifier with trailing return type ashish.sadanandan at gmail dot com
@ 2012-10-07 18:02 ` daniel.kruegler at googlemail dot com
  2012-10-07 18:05 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-10-07 18:02 UTC (permalink / raw)
  To: gcc-bugs


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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-10-07 18:02:17 UTC ---
The example works in 4.8 HEAD.


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

* [Bug c++/54849] Override specifier with trailing return type
  2012-10-07 17:42 [Bug c++/54849] New: Override specifier with trailing return type ashish.sadanandan at gmail dot com
  2012-10-07 18:02 ` [Bug c++/54849] " daniel.kruegler at googlemail dot com
@ 2012-10-07 18:05 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-07 18:05 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-07 18:04:52 UTC ---
Indeed it does.


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

end of thread, other threads:[~2012-10-07 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-07 17:42 [Bug c++/54849] New: Override specifier with trailing return type ashish.sadanandan at gmail dot com
2012-10-07 18:02 ` [Bug c++/54849] " daniel.kruegler at googlemail dot com
2012-10-07 18: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).