Bug 63391 - Erroneous -Wsign-conversion with offsetof
Summary: Erroneous -Wsign-conversion with offsetof
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.2
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2014-09-27 18:53 UTC by Ian Mallett
Modified: 2016-10-25 09:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Mallett 2014-09-27 18:53:45 UTC
//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;
}