Reputation: 63820
The program below involves a function parameter that is implicitly narrowed. Information is potentially lost.
void func(short) {}
int main()
{
int i = 0x7fffffff;
func(i);
}
If I compile this program (either as C or C++) with gcc using -Wall -Wextra
I receive no warnings!
Surely, this behavior would often be considered undesirable.
Is there some gcc command-line parameter that would trigger a diagnostic message when these narrowing conversions occur?
Upvotes: 5
Views: 1040