[Bug c++/57555] New: Warning on negation of constexpr uint8_t being assigned to uint8_t
megari at mbnet dot fi
gcc-bugzilla@gcc.gnu.org
Fri Jun 7 11:34:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57555
Bug ID: 57555
Summary: Warning on negation of constexpr uint8_t being
assigned to uint8_t
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: megari at mbnet dot fi
The following code produces a warning when it probably should not:
$ cat constexprbug.cpp
#include <cstdint>
uint8_t foo() {
static constexpr uint8_t foo = 0xff;
uint8_t ret = ~foo;
return ret;
}
uint8_t bar() {
static constexpr uint8_t foo = 0x00;
uint8_t ret = ~foo;
return ret;
}
int main() {
foo();
bar();
}
$ g++ -std=c++11 -o constexprbug constexprbug.cpp
constexprbug.cpp: In function ‘uint8_t foo()’:
constexprbug.cpp:6:20: warning: large integer implicitly truncated to unsigned
type [-Woverflow]
$ gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The curious thing is that only the function foo() produces the warning. Also,
the variable needs to be constexpr for the warning to be emitted.
More information about the Gcc-bugs
mailing list