Collin Funk wrote:
> > "../../../gettext-tools/gnulib-lib/string-desc.h", line 674.24: 1506-1332 
> > (W) A function with return type "void" may not return a value of type 
> > "void".
> >
> > Fixed like this:
> 
> Do gcc and clang not warn about this?

With option '-pedantic', they warn, yes:

$ cat foo.c
extern void foobar (int);
void foo (int x) { return foobar (x); }

$ gcc -Wall -S -pedantic foo.c
foo.c: In function ‘foo’:
foo.c:2:27: warning: ISO C forbids ‘return’ with expression, in function 
returning void [-Wpedantic]
    2 | void foo (int x) { return foobar (x); }
      |                           ^~~~~~~~~~

$ clang -Wall -S -pedantic foo.c
foo.c:2:20: warning: void function 'foo' should not return void expression 
[-Wpedantic]
    2 | void foo (int x) { return foobar (x); }
      |                    ^      ~~~~~~~~~~

I thought that 'return' of a void expression was documented as a GCC
extension. But I can't find it in the documentation now.

Bruno




Reply via email to