Ralph Spitzner <> writes:
> Keith Thompson wrote:
> [...]
>>
>> the compiler is not required to diagnose the error -- but neither is it
>> required to generate any code for the printf() call. (And with gcc, it
>> can produce no output or crash with a segmentation fault, depending on
>> the optimization level).
>
> Ok, got it now, sorry Willem too, didn't mean to offend.
> Maybe I'm just getting old, not seeing advantages of
> this or that keyword/qualifier
In general, the advantage of such qualifiers (restrict, noreturn
-- even register) is to give more information to the compiler.
In most cases, the compiler is free to ignore that information,
but it provides an opportunity for optimization.
In many cases, the information is in the form of a promise made
by the programmer to the compiler. The compiler is free to rely
on that promise -- and if the programmer has lied (e.g., using
`noreturn` on a function that does return to its caller), then the
compiler can take bloody revenge (or, more realistically, generate
code that doesn't behave as it would in the absence of the promise).
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"