svn commit: r287217 - head/usr.sbin/syslogd

Joerg Sonnenberger joerg at britannica.bec.de
Sun Aug 30 17:02:58 UTC 2015


On Sun, Aug 30, 2015 at 11:53:00AM +0200, Ed Schouten wrote:
> 2015-08-28 16:38 GMT+02:00 Joerg Sonnenberger <joerg at britannica.bec.de>:
> > But the compiler can't tell if it is the *intention* that the function
> > never returns. The warning behavior exists because that can easily
> > change with macros etc.
> 
> I think it's important to keep in mind what this keyword was designed for.
> 
> The idea behind this attribute (and the C11 _Noreturn keyword) is to
> allow for propagation of optimisation state across compilation units.
> You use it to annotate functions in header files, so that the compiler
> does not need to handle function return at the call site. This
> knowledge can be automatically be inferred if the function is static.

I disagree that optimisation is the primary design goal. Static analysis
and optimisation just have a huge overlap in this area.

> I agree with Bruce that this change makes little sense. I would even
> go as far as to say that GCC/Clang should just throw warnings if
> _Noreturn is used on a function that is static or used on a definition
> instead of a declaration.

That makes no sense. The presence of the attribute allows the compiler
to *ensure* that the function really does not return. Having done this
in NetBSD, I can assure you that there are often enough cases where the
compiler can not figure it out automatically, especially if the
attribution is missing on some function pulled in externally. GCC at
least up to 4.8 has not warned about such cases and I have multiple bugs
where function *could* fall through.

Joerg


More information about the svn-src-all mailing list