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

            Bug ID: 107388
           Summary: GCC should diagnose unsigned to signed conversion
                    with -Wconversion
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nikolasklauser at berlin dot de
  Target Milestone: ---

It looks like GCC currently doesn't diagnose a conversion from unsigned int to
int, but as I understand it -Wconversion should diagnose any conversion that
might change the value.

Here is an example: (Godbolt: https://godbolt.org/z/Mr8KvTW66)

#include <cstddef>
#include <cstdlib>

void func(unsigned int size) {
  [[maybe_unused]] int v = size; // doesn't get diagnosed
}

Reply via email to