[Bug c/60591] Report enum conversions as part of Wconversion

jg at jguk dot org gcc-bugzilla@gcc.gnu.org
Fri Apr 19 13:00:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60591

--- Comment #4 from Jonny Grant <jg at jguk dot org> ---
Clang++ gives a nice error, can gcc improve to also make it clear it is an
enum?


-Wall -Wconversion -Wextra
1
<Compilation failed>
<Compilation failed>
Find
x86-64 clang (trunk) - 349ms
#1 with x86-64 clang (trunk)
<source>:8:9: error: assigning to 'enum hello' from incompatible type 'enum
things'
    h = a;
        ^
1 error generated.
Compiler returned: 1


#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':
<source>:8:9: error: cannot convert 'things' to 'hello' in assignment
    8 |     h = a;
      |         ^
      |         |
      |         things
Compiler returned: 1


enum things { thing=-1 };
enum hello {t};
int main()
{
    enum things a;
    a= thing;
    enum hello h;
    h = a;
    return (int)a;
}


More information about the Gcc-bugs mailing list