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

            Bug ID: 91578
           Summary: bool to size_t warning  -Wsigned-conversion
           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: ---

PR created after discussion on gcc-help

https://gcc.gnu.org/ml/gcc-help/2019-08/msg00082.html



Could I suggest -Wsigned-conversion should ignore warnings about bool being
added to a bool and then converted to a size_t "signed bool" does not make
sense was one of the comments.

int main()
{
    bool a = false;
    bool b = true;
    //size_t i = a;
    size_t i = a + b;

    return i;
}

#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':

<source>:9:18: error: conversion to 'size_t' {aka 'long unsigned int'}
from 'int' may change the sign of the result [-Werror=sign-conversion]

      9 |     size_t i = a + b;

        |                ^

cc1plus: some warnings being treated as errors

Compiler returned: 1

Reply via email to