This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/46766] Type 'void' is treated differently if used as return value or as parameter


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]