[Bug other/85778] unexpected results with -O2, wrong code?

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 15 20:17:00 GMT 2018


Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Scott Emmons from comment #4)
> > glibc has stat annotated with nonnull(1, 2)
> 1. Can you provide a reference to this code? This is helpful so that other
> people running into this (and it *will* happen, this ancient code no longer
> runs correctly). Thank you.

stat() is a POSIX function and (similarly to C) POSIX specifies (in 2.1.1 Use
and Implementation of Functions of XSH) that:

If an argument to a function has an invalid value (such as a value outside the
domain of the function, or a pointer outside the address space of the program,
or a null pointer), the behavior is undefined.

A link to the section in the latest spec:

More information about the Gcc-bugs mailing list