Hi!
On Thu, May 20, 2021 at 05:37:20PM +1000, Michael Ellerman wrote:
Segher Boessenkool [off-list ref] writes:
quoted
On Tue, May 18, 2021 at 07:45:14PM -0500, Segher Boessenkool wrote:
quoted
On Wed, May 19, 2021 at 10:26:22AM +1000, Michael Ellerman wrote:
quoted
Guenter Roeck [off-list ref] writes:
quoted
Ah, sorry. I wasn't aware that the following is valid C code
void f1()
{
return f2();
^^^^^^
}
as long as f2() is void as well. Confusing, but we live and learn.
It might be valid, but it's still bad IMHO.
It's confusing to readers, and serves no useful purpose.
And it actually explicitly is undefined behaviour in C90 already
(3.6.6.4 in C90, 6.8.6.4 in C99 and later).
We use gnu89, which presumably does not make it UB.
Indeed. That is kind of implied by the "as a GNU extension" below, but
some explicit statement would be better, yup.
quoted
... but there is a GCC extension that allows this by default:
<https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wreturn-type>
For C only, warn about a 'return' statement with an expression in a
function whose return type is 'void', unless the expression type is
also 'void'. As a GNU extension, the latter case is accepted
without a warning unless '-Wpedantic' is used.
There's no chance we'll ever enable -Wpedantic,
Good, because -pedantic adds a lot of much more annoying warnings as
well. I find this extension questionable (like Guenter says it is
confusing and has no purpose), so the only thing it is "good" for is it
causes long email threads ;-)
Other than those things it is harmless though.
so I guess it's allowed
for practical purposes. I guess clang must accept it too or we'd be
seeing warnings from it.
Yup.
Segher