Ö
Öö Tiib
In C++ we can have void return type and we can "return" it:
void foo();
void bar()
{
return (void)42; // ok #1
return foo(); // ok #2
}
Fun way to confuse novices indeed. However, it appears that we can not (for
whatever unknown reason) pass void arguments:
void bad()
{
foo((void)42); // illegal
}
Even if I think I will be extra clever and add overload of 'foo' that supposedly
accepts anything ...
void foo(...);
.... then I get different failures or successes on different mac/ubuntu clang/gcc
versions. Seems that compilers are confused.
Is there reason why we have such inconsistency?
void foo();
void bar()
{
return (void)42; // ok #1
return foo(); // ok #2
}
Fun way to confuse novices indeed. However, it appears that we can not (for
whatever unknown reason) pass void arguments:
void bad()
{
foo((void)42); // illegal
}
Even if I think I will be extra clever and add overload of 'foo' that supposedly
accepts anything ...
void foo(...);
.... then I get different failures or successes on different mac/ubuntu clang/gcc
versions. Seems that compilers are confused.
Is there reason why we have such inconsistency?