[Bug c/86053] Builtin fwrite arguments have non_null attribute and builtin function declaration not overloaded

2018-06-06 Thread olivier at wuillemin dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86053

--- Comment #2 from olivier at wuillemin dot fr ---
Resolved ? I find your answer a little bit short.

Concerning the nonnull attribute, in glibc manual i didn't find any requirement
 concerning pointer arguments neither in glibc doc :

size_t fwrite(const void *data, size_t size, size_t count, FILE *stream)
Preliminary: | MT-Safe | AS-Unsafe  corrupt | AC-Unsafe  lock  corrupt | See
Section 1.2.2.1 [POSIX Safety Concepts], page 2.

This  function  writes  up  to count objects of  size size from  the  array
data,  to  the stream stream.  The return value is normally count, if the call
succeeds. Any other value indicates some sort of error, such as running out of
space.

Neither in glibc's stdio.h source :

/* Write chunks of generic data to STREAM.
   This function is a possible cancellation point and therefore not
   marked with __THROW.  */
extern size_t fwrite (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s);

For information VS studio indicates that function generate a runtime parameter
error in case of null pointer.

And if non null pointers are mandatorty for fwrite why they are not mandatory
for fread ?

Also, this doesn't explain why local declaration of a function is overloaded
with built-in declaration.

[Bug c/86053] Builtin fwrite arguments have non_null attribute and builtin function declaration not overloaded

2018-06-05 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86053

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Andrew Pinski  ---
I don't see this as a real issue as the C standard has a requirement that the
FILE* argument should be non-null; otherwise it is undefined behavior at
runtime.  Using -fno-builtins or -ffree-standing is the correct fix here.