public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115580] New: decltype of nullptr error with -Werror=nonnull
@ 2024-06-21 13:19 marcpawl at gmail dot com
2024-06-21 14:07 ` [Bug c++/115580] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
2024-06-21 17:33 ` [Bug c++/115580] [11/12/13/14/15 regression] null pointer warning from an unevaluated context pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: marcpawl at gmail dot com @ 2024-06-21 13:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115580
Bug ID: 115580
Summary: decltype of nullptr error with -Werror=nonnull
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marcpawl at gmail dot com
Target Milestone: ---
-Werror=nonnull returns error when using nullptr to get type of member
function.
Even though we are using -Werror=nonnull, there should be no diagnostic
since the function is never evaluated, and it is non-virtual.
https://godbolt.org/z/3oh1199Wh
https://stackoverflow.com/questions/5580253/how-do-i-get-the-return-type-of-a-member-function-without-an-object
class WithMember {
public:
int foo();
};
decltype(((WithMember*)nullptr)->foo()) footype;
<source>:7:37: error: 'this' pointer is null [-Werror=nonnull]
7 | decltype(((WithMember*)nullptr)->foo()) footype;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
<source>:4:7: note: in a call to non-static member function 'int
WithMember::foo()'
4 | int foo();
| ^~~
<source>:7:37: error: 'this' pointer is null [-Werror=nonnull]
7 | decltype(((WithMember*)nullptr)->foo()) footype;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
<source>:4:7: note: in a call to non-static member function 'int
WithMember::foo()'
4 | int foo();
| ^~~
cc1plus: some warnings being treated as errors
Compiler returned: 1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/115580] [11/12/13/14/15 regression] decltype of nullptr error with -Werror=nonnull
2024-06-21 13:19 [Bug c++/115580] New: decltype of nullptr error with -Werror=nonnull marcpawl at gmail dot com
@ 2024-06-21 14:07 ` sjames at gcc dot gnu.org
2024-06-21 17:33 ` [Bug c++/115580] [11/12/13/14/15 regression] null pointer warning from an unevaluated context pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-21 14:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115580
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|decltype of nullptr error |[11/12/13/14/15 regression]
|with -Werror=nonnull |decltype of nullptr error
| |with -Werror=nonnull
--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
10 works.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/115580] [11/12/13/14/15 regression] null pointer warning from an unevaluated context
2024-06-21 13:19 [Bug c++/115580] New: decltype of nullptr error with -Werror=nonnull marcpawl at gmail dot com
2024-06-21 14:07 ` [Bug c++/115580] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
@ 2024-06-21 17:33 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-21 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115580
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-06-21
Status|UNCONFIRMED |NEW
Target Milestone|--- |11.5
Summary|[11/12/13/14/15 regression] |[11/12/13/14/15 regression]
|decltype of nullptr error |null pointer warning from
|with -Werror=nonnull |an unevaluated context
Ever confirmed|0 |1
Known to fail| |11.1.0
Known to work| |10.1.0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The this pointer case was introduced by r11-6900-gd6f1cf644c45b7 (and )
BUT this has always been an issue:
```
int f(void*) __attribute__((nonnull));
void g()
{
decltype(f(nullptr)) b;
}
```
This should not warn since we are inside an unevaluated context.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-21 17:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21 13:19 [Bug c++/115580] New: decltype of nullptr error with -Werror=nonnull marcpawl at gmail dot com
2024-06-21 14:07 ` [Bug c++/115580] [11/12/13/14/15 regression] " sjames at gcc dot gnu.org
2024-06-21 17:33 ` [Bug c++/115580] [11/12/13/14/15 regression] null pointer warning from an unevaluated context pinskia 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).