2 ms·
Your understanding is incomplete. $ gcc -c test.c test.c: In function ‘foo’: test.c:3:12: warning: return makes pointer from integer without a cast [-Win
by kazinator 4y ago
Your understanding is incomplete.
$ gcc -c test.c
test.c: In function ‘foo’:
test.c:3:12: warning: return makes pointer from integer without a cast [-Wint-conversion]
return x;
^
The translation unit has a constraint violation, for which ISO C requires a diagnostic. The compiler supplied one.
ISO C doesn't say that translation must be terminated.
ISO C doesn't define different classes of diagnostic like "error" or "warning".
I didn't tell GCC to be an ISO C compiler. The above diagnostic tells us that while conversions from integers to pointers happen implicitly, the GNU C dialect, like ISO C, wants that diagnosed. You have to go out of your way to modify the dialect not to have that diagnosed, like:
$ gcc -Wno-int-conversion -c test.c
$
That's not GNU C any more, but a tweaked sub-dialect of GNU C with a diagnostic requirement removed.