Bug 60591 added -Wenum-conversion for C Could this be added for C++ too? #1 with x86-64 gcc (trunk) cc1plus: error: command-line option '-Wenum-conversion' is valid for C/ObjC but not for C++ [-Werror] cc1plus: all warnings being treated as errors Compiler returned: 1 Test case enum xpto { A = 0, B = 1, X = 512 }; extern void print (unsigned int); unsigned char bar (enum xpto a) { return a; }
Your testcase doesn't warn for C.
(In reply to Jonny Grant from comment #0) > Bug 60591 added -Wenum-conversion for C I think you mean Bug 78736, and the C option doesn't warn for your testcase. It warns for conversions from one enumeration type to another enumeration type, which is already ill-formed in C++. Adding a warning for something that doesn't compile anyway is useless. Please clarify exactly what you're asking for.
This doesn't seem to warn with Clang or Clang++ either.
My apologies, I tested with the correct test case and it already does not compile in C++ as desired, so no -Wenum-conversion required. #include <stdio.h> typedef enum {brandon, jon, mitch} name_t; typedef enum {fred, dog, cat} name2_t; name2_t name = brandon; name_t hik = 3; int hal_entry(void) { if (hik < name) return(0); return 1; } int main () { printf ("%d\n", hal_entry()); return 0; }
Thanks, let's close this then.