Bug 13268 - modf, modff, modfl: help GCC with argument checking
Summary: modf, modff, modfl: help GCC with argument checking
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.11
: P2 normal
Target Milestone: ---
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-05 23:43 UTC by Bruno Haible
Modified: 2014-06-27 11:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2011-10-05 23:43:45 UTC
The second argument of the functions modf, modff, modfl must not be a NULL
pointer, according to POSIX, and the glibc implementation also does not allow
a NULL pointer.

It would be useful to allow GCC to give a warning when someone passes a NULL
literal to these functions.

How to reproduce:
==================== foo.c ========================
#include <math.h>
#include <stddef.h>
int
main ()
{
  return ! modf (2.4, NULL);
}
===================================================
$ gcc -Wall foo.c

Expected result:
foo.c: In function 'main':
foo.c:6:3: warning: null argument where non-null required (argument 2)

Actual result:
No diagnostic.

The fix should be easy: Add a properly conditionalized
__attribute__ ((__nonnull__ (2)))
to glibc/math/bits/mathcalls.h line 116.
Comment 1 Andreas Jaeger 2011-10-12 12:36:01 UTC
Thanks. I send a patch to libc-alpha for this.
Comment 2 Ulrich Drepper 2011-10-15 14:09:07 UTC
Changed in git.