public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114129] New: Inaccurate error message
@ 2024-02-27 13:30 Theodore.Papadopoulo at inria dot fr
  2024-02-27 13:45 ` [Bug c++/114129] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Theodore.Papadopoulo at inria dot fr @ 2024-02-27 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114129

            Bug ID: 114129
           Summary: Inaccurate error message
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Theodore.Papadopoulo at inria dot fr
  Target Milestone: ---

Given the code below

struct A {
    virtual void f() { }
};

struct B: public A {
    void f() override() { }
};

The g++ compiler gives the following error:
-> g++ -O3 test.cpp 
test.cpp:6:5: error: ‘f’ declared as function returning a function
    6 |     void f() override() { }
      |     ^~~~

Technically, it should be 'override' declared as function returning a function.
or even maybe that override is a reserved name and cannot be used as a function
name...

Yet this is much better than clang:
-> clang++ -O3 test.cpp
test.cpp:6:22: error: expected ';' at end of declaration list
    6 |     void f() override() { }
      |                      ^
      |                      ;
1 error generated.

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

* [Bug c++/114129] Inaccurate error message
  2024-02-27 13:30 [Bug c++/114129] New: Inaccurate error message Theodore.Papadopoulo at inria dot fr
@ 2024-02-27 13:45 ` redi at gcc dot gnu.org
  2024-02-28 13:24 ` Theodore.Papadopoulo at inria dot fr
  2024-02-28 13:25 ` Theodore.Papadopoulo at inria dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-27 13:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114129

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Theodore.Papadopoulo from comment #0)
> Technically, it should be 'override' declared as function returning a
> function.

No, GCC is correct here, according to the grammar ... or as much as you can
reason about how the grammar applies to code that doesn't conform to the
grammar.

The function declarator is `f() override` and the return type is `void()`.

You get exactly the same error without the override:

o.cc:6:5: error: ‘f’ declared as function returning a function
    6 |     void f()() { }
      |     ^~~~


> or even maybe that override is a reserved name and cannot be used as a
> function name...

That would definitely be wrong though. It's not reserved, it's "an identifier
with special meaning", and `void override() { }` is perfectly valid as a
function declaration.

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

* [Bug c++/114129] Inaccurate error message
  2024-02-27 13:30 [Bug c++/114129] New: Inaccurate error message Theodore.Papadopoulo at inria dot fr
  2024-02-27 13:45 ` [Bug c++/114129] " redi at gcc dot gnu.org
@ 2024-02-28 13:24 ` Theodore.Papadopoulo at inria dot fr
  2024-02-28 13:25 ` Theodore.Papadopoulo at inria dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore.Papadopoulo at inria dot fr @ 2024-02-28 13:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114129

--- Comment #2 from Theodore.Papadopoulo at inria dot fr ---
OK thank you... I did not realize that. C/C++ sometimes has a weird syntax.
Sorry for the noise....

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

* [Bug c++/114129] Inaccurate error message
  2024-02-27 13:30 [Bug c++/114129] New: Inaccurate error message Theodore.Papadopoulo at inria dot fr
  2024-02-27 13:45 ` [Bug c++/114129] " redi at gcc dot gnu.org
  2024-02-28 13:24 ` Theodore.Papadopoulo at inria dot fr
@ 2024-02-28 13:25 ` Theodore.Papadopoulo at inria dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore.Papadopoulo at inria dot fr @ 2024-02-28 13:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114129

Theodore.Papadopoulo at inria dot fr changed:

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

--- Comment #3 from Theodore.Papadopoulo at inria dot fr ---
Wrong report.... Sorry.

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

end of thread, other threads:[~2024-02-28 13:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 13:30 [Bug c++/114129] New: Inaccurate error message Theodore.Papadopoulo at inria dot fr
2024-02-27 13:45 ` [Bug c++/114129] " redi at gcc dot gnu.org
2024-02-28 13:24 ` Theodore.Papadopoulo at inria dot fr
2024-02-28 13:25 ` Theodore.Papadopoulo at inria dot fr

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