public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration"
@ 2020-07-08 15:44 haoxintu at gmail dot com
  2020-07-08 16:13 ` [Bug c++/96120] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-08 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96120
           Summary: Ambiguity diagnostic message of "invalid use of type
                    'void' in parameter declaration"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, test.cc, GCC might emit the ambiguity diagnostic message on it.

$cat test.cc
void foo1 (void) {}
void foo2 (void, int){}

$g++ -c test.cc
test.cc:2:12: error: invalid use of type ‘void’ in parameter declaration
    2 | void foo2 (void, int){}
      |            ^~~~

Apparently, "void" can be used in parameter declaration like line 1, but GCC
emits the ambiguity message on it. The output information conflicts with valid
grammar, so I guess users might be confused with this diagnostic.

I think clang handles better in this case

$clang++ -c test.cc
test.cc:2:11: error: 'void' must be the first and only parameter if specified
void foo2 (void, int){}
          ^
1 error generated.

Thanks,
Haoxin

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

* [Bug c++/96120] Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration"
  2020-07-08 15:44 [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration" haoxintu at gmail dot com
@ 2020-07-08 16:13 ` redi at gcc dot gnu.org
  2020-07-08 16:15 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-08 16:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Haoxin Tu from comment #0)
> GCC might emit the ambiguity diagnostic message on it.

What does that mean?

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

* [Bug c++/96120] Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration"
  2020-07-08 15:44 [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration" haoxintu at gmail dot com
  2020-07-08 16:13 ` [Bug c++/96120] " redi at gcc dot gnu.org
@ 2020-07-08 16:15 ` redi at gcc dot gnu.org
  2020-07-08 16:21 ` haoxintu at gmail dot com
  2020-07-08 19:33 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-08 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC's diagnostic seems fine to me. Using 'void' as the type of a parameter is
invalid. There's a special case for (void) but that isn't relevant to your
declaration, which has two parameters.

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

* [Bug c++/96120] Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration"
  2020-07-08 15:44 [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration" haoxintu at gmail dot com
  2020-07-08 16:13 ` [Bug c++/96120] " redi at gcc dot gnu.org
  2020-07-08 16:15 ` redi at gcc dot gnu.org
@ 2020-07-08 16:21 ` haoxintu at gmail dot com
  2020-07-08 19:33 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-08 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to Haoxin Tu from comment #0)
> > GCC might emit the ambiguity diagnostic message on it.
> 
> What does that mean?

Apologize for my expression. I mean the meaning of the error message "invalid
use of type ‘void’ in parameter declaration" is opposite with the valid
grammar(it should be allowed in the first parameter).

This might be not a bug, might be just an improvement?

Thanks.

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

* [Bug c++/96120] Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration"
  2020-07-08 15:44 [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration" haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-07-08 16:21 ` haoxintu at gmail dot com
@ 2020-07-08 19:33 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-08 19:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Haoxin Tu from comment #3)
> Apologize for my expression. I mean the meaning of the error message
> "invalid use of type ‘void’ in parameter declaration" is opposite with the
> valid grammar(it should be allowed in the first parameter).

No, it's not the opposite at all.

void is only allowed when there is a single, unnamed non-dependent parameter of
type void. Any other use is void is invalid, including the case where you have
(void, int). And so GCC's error message is absolutely correct. Using void in a
parameter list with more than one parameter is invalid.

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

end of thread, other threads:[~2020-07-08 19:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 15:44 [Bug c++/96120] New: Ambiguity diagnostic message of "invalid use of type 'void' in parameter declaration" haoxintu at gmail dot com
2020-07-08 16:13 ` [Bug c++/96120] " redi at gcc dot gnu.org
2020-07-08 16:15 ` redi at gcc dot gnu.org
2020-07-08 16:21 ` haoxintu at gmail dot com
2020-07-08 19:33 ` redi 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).