public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114808] New: Qualified void return type is not diagnosed
@ 2024-04-22 17:02 luigighiron at gmail dot com
  2024-04-22 19:11 ` [Bug c/114808] " jakub at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: luigighiron at gmail dot com @ 2024-04-22 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114808
           Summary: Qualified void return type is not diagnosed
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luigighiron at gmail dot com
  Target Milestone: ---

The following code is accepted in GCC with no diagnostics being produced (even
when using -pedantic-errors):

const void f(void){}

This code violates the following constraint:

> The return type of a function shall be void or a complete object type other
> than array type.
Section 6.9.1 "Function definitions" Paragraph 3 ISO/IEC 9899:2018

const void is not void and it is not a complete object type.

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
@ 2024-04-22 19:11 ` jakub at gcc dot gnu.org
  2024-04-22 19:15 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-22 19:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't see such a sentence in C++17 nor other C++ standards.
All compilers I've tried accept it.
On the other side, e.g. http://eel.is/c++draft/basic.fundamental#15 talks about
functions returning cv void.
Similarly http://eel.is/c++draft/stmt.return#2
And
https://eel.is/c++draft/dcl.fct#14 explicitly says
"The return type shall be a non-array object type, a reference type, or cv
void."
This is something that was earlier said in [expr.call]/3 (e.g. in C++17,
[expr.call]/5 in C++20).

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
  2024-04-22 19:11 ` [Bug c/114808] " jakub at gcc dot gnu.org
@ 2024-04-22 19:15 ` pinskia at gcc dot gnu.org
  2024-04-22 19:17 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-22 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> I don't see such a sentence in C++17 nor other C++ standards.

It was reported for C, not C++ :).

Anyways clang rejects it in C mode (with -pedantic-errors):
```
<source>:1:13: error: function cannot return qualified void type 'const void'
[-Werror,-Wqualified-void-return-type]
    1 | const void f(void){}
      |             ^

```

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
  2024-04-22 19:11 ` [Bug c/114808] " jakub at gcc dot gnu.org
  2024-04-22 19:15 ` pinskia at gcc dot gnu.org
@ 2024-04-22 19:17 ` jakub at gcc dot gnu.org
  2024-04-22 19:34 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-22 19:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Oops, I'm blind.

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (2 preceding siblings ...)
  2024-04-22 19:17 ` jakub at gcc dot gnu.org
@ 2024-04-22 19:34 ` pinskia at gcc dot gnu.org
  2024-04-22 19:42 ` luigighiron at gmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-22 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. clang added the warning/error back in 2015 ...

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (3 preceding siblings ...)
  2024-04-22 19:34 ` pinskia at gcc dot gnu.org
@ 2024-04-22 19:42 ` luigighiron at gmail dot com
  2024-04-22 19:46 ` luigighiron at gmail dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: luigighiron at gmail dot com @ 2024-04-22 19:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Halalaluyafail3 <luigighiron at gmail dot com> ---
I made this bug report because of the warning that clang has, but the following
paragraph may allow this:

> If, in the declaration "T D1", D1 has the form
> D ( parameter-type-list )
> or
> D ( identifier-list opt )
> and the type specified for ident in the declaration "T D" is
> "derived-declarator-type-list T", then the type specified for
> ident is "derived-declarator-type-list function returning the
> unqualified version of T".
Section 6.7.6.3 "Function declarators (including prototypes)" Paragraph 4
ISO/IEC 9899:2018

GCC seems to be using this to not make a diagnostic here, e.g. it warns with a
return type of _Atomic void in C17 mode but not in C23 mode where the text here
was updated to indicate that the result is the unqualified and non-atomic
version of T. If this would make the text talking about the return type of the
function refer to the unqualified return type then this should be allowed I
think, and I will make a bug report to clang to get this diagnostic changed.

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (4 preceding siblings ...)
  2024-04-22 19:42 ` luigighiron at gmail dot com
@ 2024-04-22 19:46 ` luigighiron at gmail dot com
  2024-04-22 19:54 ` jsm28 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: luigighiron at gmail dot com @ 2024-04-22 19:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Halalaluyafail3 <luigighiron at gmail dot com> ---
* Paragraph 5 instead of Paragraph 4

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (5 preceding siblings ...)
  2024-04-22 19:46 ` luigighiron at gmail dot com
@ 2024-04-22 19:54 ` jsm28 at gcc dot gnu.org
  2024-04-22 20:11 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-04-22 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Yes, this is deliberate following the resolution of DR#423 which means
qualifiers are ignored on function return types (it's still diagnosed in
pre-C11 modes).

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (6 preceding siblings ...)
  2024-04-22 19:54 ` jsm28 at gcc dot gnu.org
@ 2024-04-22 20:11 ` pinskia at gcc dot gnu.org
  2024-04-23  1:12 ` luigighiron at gmail dot com
  2024-04-23  5:54 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-22 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://github.com/llvm/llvm-project/issues/39494 is the clang issue dealing
with DR 423 .

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (7 preceding siblings ...)
  2024-04-22 20:11 ` pinskia at gcc dot gnu.org
@ 2024-04-23  1:12 ` luigighiron at gmail dot com
  2024-04-23  5:54 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: luigighiron at gmail dot com @ 2024-04-23  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

Halalaluyafail3 <luigighiron at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #9 from Halalaluyafail3 <luigighiron at gmail dot com> ---
Resolving since I feel that the current behavior here is correct after looking
at the text in the standard enough. -Wignored-qualifiers also seems to cover
this case so adding a new warning shouldn't be needed either.

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

* [Bug c/114808] Qualified void return type is not diagnosed
  2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
                   ` (8 preceding siblings ...)
  2024-04-23  1:12 ` luigighiron at gmail dot com
@ 2024-04-23  5:54 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-23  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xry111 at gcc dot gnu.org
         Resolution|FIXED                       |INVALID

--- Comment #10 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
So this is not a valid bug report considering DR 423.

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

end of thread, other threads:[~2024-04-23  5:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 17:02 [Bug c/114808] New: Qualified void return type is not diagnosed luigighiron at gmail dot com
2024-04-22 19:11 ` [Bug c/114808] " jakub at gcc dot gnu.org
2024-04-22 19:15 ` pinskia at gcc dot gnu.org
2024-04-22 19:17 ` jakub at gcc dot gnu.org
2024-04-22 19:34 ` pinskia at gcc dot gnu.org
2024-04-22 19:42 ` luigighiron at gmail dot com
2024-04-22 19:46 ` luigighiron at gmail dot com
2024-04-22 19:54 ` jsm28 at gcc dot gnu.org
2024-04-22 20:11 ` pinskia at gcc dot gnu.org
2024-04-23  1:12 ` luigighiron at gmail dot com
2024-04-23  5:54 ` xry111 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).