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

            Bug ID: 101537
           Summary: -Wconversion false positive in ternary
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at xenu dot pl
  Target Milestone: ---

The following code:

int foo() {
    int aaa = 1;
    unsigned char bbb = 0;
    bbb |= aaa ? 1 : 0;
    return bbb;
}

Gives this warning:

<source>: In function 'foo':
<source>:4:12: warning: conversion from 'int' to 'unsigned char' may change
value [-Wconversion]
    4 |     bbb |= aaa ? 1 : 0;
      |            ^~~
Compiler returned: 0

It happens both in C and C++ modes.

Reply via email to