Issue 185400
Summary [clang] [diagnostics] Wrong -Wimplicit-int-enum-cast warning
Labels clang
Assignees
Reporter Pheeck
    Compile this C code snippet with trunk Clang using -Wc++-compat

```
void free(void *p);

typedef enum
{
  REG_EBRACE,
  REG_BADBR,
} reg_errcode_t;

#  define FREE_STACK_RETURN(value)              \
 return (free (compile_stack.stack), value)

reg_errcode_t
regex_compile (void *bufp)
{
  struct { int *stack; int b;} compile_stack;
 FREE_STACK_RETURN (bufp ? REG_EBRACE : REG_BADBR);
}
```

Clang will complain

```
<source>:16:22: warning: implicit conversion from 'int' to enumeration type 'reg_errcode_t' is invalid in C++ [-Wimplicit-int-enum-cast]
   16 |   FREE_STACK_RETURN (bufp ? REG_EBRACE : REG_BADBR);
      | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:10:39: note: expanded from macro 'FREE_STACK_RETURN'
   10 |   return (free (compile_stack.stack), value)
      |                                     ~ ^~~~~
```

But this warning doesn't make sense. As far as I can tell, no int is involved. No implicit conversion from int should be happening. GCC doesn't generate any similar warning:
https://godbolt.org/z/WdMxbYjTz
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to