public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110815] New: [static] not as useful as the nonnull attribute
@ 2023-07-26 13:45 muecker at gwdg dot de
2023-07-26 14:24 ` [Bug c/110815] " muecker at gwdg dot de
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: muecker at gwdg dot de @ 2023-07-26 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
Bug ID: 110815
Summary: [static] not as useful as the nonnull attribute
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: muecker at gwdg dot de
Target Milestone: ---
C code increasingly uses
void foo(char buf[static 10]);
to indicate that buf is a non-null pointer.
GCC already has some warnings for this but all you would get with the nonnull
attribute. In particular, -Wnonnull-compare is missing.
void
foo (int a[static 1])
{
if ((void*)0 == a) // should warn
return;
}
https://godbolt.org/z/E6E33Pa8h
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110815] [static] not as useful as the nonnull attribute
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
@ 2023-07-26 14:24 ` muecker at gwdg dot de
2023-11-11 9:39 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: muecker at gwdg dot de @ 2023-07-26 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
--- Comment #1 from Martin Uecker <muecker at gwdg dot de> ---
Created attachment 55638
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55638&action=edit
patch
This patch would synthesize a nonnull attribute for such parameters, making
this fully equivalent.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110815] [static] not as useful as the nonnull attribute
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
2023-07-26 14:24 ` [Bug c/110815] " muecker at gwdg dot de
@ 2023-11-11 9:39 ` cvs-commit at gcc dot gnu.org
2023-11-11 10:15 ` xry111 at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-11 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>:
https://gcc.gnu.org/g:c58b426d64ac2513dc0ed19165740604e891e9df
commit r14-5353-gc58b426d64ac2513dc0ed19165740604e891e9df
Author: Martin Uecker <uecker@tugraz.at>
Date: Thu Jul 27 13:41:33 2023 +0200
c: Synthesize nonnull attribute for parameters declared with static
[PR110815]
Parameters declared with `static` are nonnull. We synthesize
an artifical nonnull attribute for such parameters to get the
same warnings and optimizations.
Bootstrapped and regression tested on x86.
PR c/110815
PR c/112428
gcc/c-family:
* c-attribs.cc (build_attr_access_from_parms): Synthesize
nonnull attribute for parameters declared with `static`.
gcc:
* gimple-ssa-warn-access.cc
(pass_waccess::maybe_check_access_sizes):
remove warning for parameters declared with `static`.
gcc/testsuite:
* gcc.dg/Wnonnull-8.c: Adapt test.
* gcc.dg/Wnonnull-9.c: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110815] [static] not as useful as the nonnull attribute
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
2023-07-26 14:24 ` [Bug c/110815] " muecker at gwdg dot de
2023-11-11 9:39 ` cvs-commit at gcc dot gnu.org
@ 2023-11-11 10:15 ` xry111 at gcc dot gnu.org
2023-11-11 10:20 ` uecker at gcc dot gnu.org
2023-11-11 19:03 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-11-11 10:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
IIUC this is fixed now?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110815] [static] not as useful as the nonnull attribute
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
` (2 preceding siblings ...)
2023-11-11 10:15 ` xry111 at gcc dot gnu.org
@ 2023-11-11 10:20 ` uecker at gcc dot gnu.org
2023-11-11 19:03 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: uecker at gcc dot gnu.org @ 2023-11-11 10:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
uecker at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
CC| |uecker at gcc dot gnu.org
--- Comment #4 from uecker at gcc dot gnu.org ---
Fixed on trunk.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110815] [static] not as useful as the nonnull attribute
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
` (3 preceding siblings ...)
2023-11-11 10:20 ` uecker at gcc dot gnu.org
@ 2023-11-11 19:03 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-11 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110815
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-11 19:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 13:45 [Bug c/110815] New: [static] not as useful as the nonnull attribute muecker at gwdg dot de
2023-07-26 14:24 ` [Bug c/110815] " muecker at gwdg dot de
2023-11-11 9:39 ` cvs-commit at gcc dot gnu.org
2023-11-11 10:15 ` xry111 at gcc dot gnu.org
2023-11-11 10:20 ` uecker at gcc dot gnu.org
2023-11-11 19:03 ` 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).