2 ms·
That's not valid standard C; gcc and clang give a warning with '-pedantic'. It's valid C++ though. And IMO it's quite a nice feature, useful sometimes for redu
by dzaima 2y ago
That's not valid standard C; gcc and clang give a warning with '-pedantic'. It's valid C++ though.
And IMO it's quite a nice feature, useful sometimes for reducing boilerplate in early returns. It's the obvious consequence if you don't treat void as some extremely-special syntax but rather as just another type, perhaps alike an empty struct (though that's not valid C either ¯\_(ツ)_/¯) that's just implicitly returned at the end of a void-returning function, and a "return;" statement implicitly "creates" a value of void.
In fact in Rust (and probably a bunch of other languages that I'm too lazy to remember) void-returning functions are done via returning a 0-tuple.
- utopcell 2y ago> warning: ISO C forbids 'return' with expression, in function returning void [-Wpedantic] Sanity restored.