This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36741] New: [4.3,4.4 regression] Bogus "large integer implicitly truncated" passing size_t constant to new
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jul 2008 07:08:40 -0000
- Subject: [Bug c++/36741] New: [4.3,4.4 regression] Bogus "large integer implicitly truncated" passing size_t constant to new
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compiling this simple C++ program with 4.3 or 4.4:
#include <stddef.h>
const char* foo() { return new char[~static_cast<size_t>(0)]; }
gives this warning:
foo.cc: In function ?const char* foo()?:
foo.cc:2: warning: large integer implicitly truncated to unsigned type
The warning is bogus: there is no truncation here. It would be reasonable to
give a warning that the new would fail, but the warning it actually gives is
simply wrong. I haven't looked into this much, but it seems to be related to
sizetype.
4.1 gives no warning. I don't have 4.2 handy.
--
Summary: [4.3,4.4 regression] Bogus "large integer implicitly
truncated" passing size_t constant to new
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36741