This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/46766] Type 'void' is treated differently if used as return value or as parameter
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 2 Dec 2010 15:14:25 +0000
- Subject: [Bug c/46766] Type 'void' is treated differently if used as return value or as parameter
- Auto-submitted: auto-generated
- References: <bug-46766-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46766
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-02 15:14:14 UTC ---
(In reply to comment #0)
>
> void f1(void)
> {
> return (void)0; //OK
This is valid in C++ but allowing it in C is a GCC extension.
> void f2(void)
> {
> return f1(); //OK
This is valid in C++ but allowing it in C is a GCC extension.
> f1((void)0); //ERROR
> f2(f1()); //ERROR
This is repulsive.
I don't see this as "more aligned" with the examples above, I see it as more
aligned with:
int i = (int) f1(); // EURGH
Or consider the following, how many arguments are given to f3?
void f3(int);
f3((void)0, f1(), f2(), 3); // EURGH