[Bug c++/92158] New: Enum warning when -1 enum converted to unsigned int or int

jg at jguk dot org gcc-bugzilla@gcc.gnu.org
Sat Oct 19 14:17:00 GMT 2019


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

            Bug ID: 92158
           Summary: Enum warning when -1 enum converted to unsigned int or
                    int
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

Could warnings for this be added for C and C++?

I tested on godbolt trunk today 19 Oct 2019.

There isn't any warning output when 'a_t' is converted to 'int'. Or even if it
was converted to an 'unsigned int'

https://gcc.gnu.org/ml/gcc-help/2019-07/msg00014.html


//-O2 -Wall -Wextra -Wconversion -Werror

#include <stddef.h>
typedef enum
{
    a = -1
} a_t;

a_t f()
{
    return a;
}

int main()
{
    int b = f();
    return b;
}


More information about the Gcc-bugs mailing list