[Bug c++/63391] New: Erroneous -Wsign-conversion with offsetof
ian at geometrian dot com
gcc-bugzilla@gcc.gnu.org
Sat Sep 27 18:53:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63391
Bug ID: 63391
Summary: Erroneous -Wsign-conversion with offsetof
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ian at geometrian dot com
//Bug report:
// by Ian Mallett
// Compile with "g++ <name.cpp> -std=c++11 -Wsign-conversion
#include <cstdint>
#include <cstddef>
struct Foo {
char data;
};
int main(int /*argc*/, char* /*argv*/[]) {
int num = 6;
#if 0 //No warning
size_t offset = offsetof(struct Foo,data);
delete [] new char[offset*static_cast<size_t>(num)];
#else //warning
delete [] new char[offsetof(struct Foo,data)*static_cast<size_t>(num)];
#endif
return 0;
}
More information about the Gcc-bugs
mailing list