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

--- Comment #1 from Jonny Grant <jg at jguk dot org> ---


Improved suggestion with the sign indicated:
const int n = 41111111111;


<source>:1:15: warning: overflow in conversion from 'long int' (signed 64bit)
to 'int' (signed 32bit) changes value from '41111111111' to '-1838561849'
[-Woverflow]
    1 | const int n = 41111111111;
      |               ^~~~~~~~~~~




Another example:
const unsigned int n = 41111111111;

Improved suggestion with the sign indicated:

<source>:1:24: warning: unsigned conversion from 'long int' (signed 64bit) to
'unsigned int' (unsigned 32bit) changes value from '41111111111' to
'2456405447' [-Woverflow]

    1 | const unsigned int n = 41111111111;

      |                        ^~~~~~~~~~~

Reply via email to