[Bug c/96740] New: frexp, modf, and remquo missing attribute nonnull
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 21 20:36:40 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96740
Bug ID: 96740
Summary: frexp, modf, and remquo missing attribute nonnull
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The math built-in functions frexp, modf, and remquo take pointers to objects
that they are specified to unconditionally store a component of the result in.
Their internal declarations should make use of attribute nonnull to trigger
-Wnonnull warnings when they're passed a null pointer.
$ cat z.c && gcc -O2 -S -Wall z.c
double f0 (double x)
{
return __builtin_frexp (x, (int*)0); // missing warning
}
double f1 (double x)
{
return __builtin_modf (x, (double*)0); // missing warning
}
double f2 (void)
{
return __builtin_nan ((char*)0); // -Wnonnull (good)
}
double f3 (double x, double y)
{
return __builtin_remquo (x, y, (int*)0); // missing warning
}
z.c: In function ‘f2’:
z.c:13:10: warning: argument 1 null where non-null expected [-Wnonnull]
13 | return __builtin_nan ((char*)0); // -Wnonnull (good)
| ^~~~~~~~~~~~~
<built-in>: note: in a call to function ‘__builtin_nan’ declared ‘nonnull’
More information about the Gcc-bugs
mailing list