This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30343] New: False positive: allocating zero-element array
- From: "gjasny at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jan 2007 18:47:05 -0000
- Subject: [Bug c/30343] New: False positive: allocating zero-element array
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
The following code produces a false positive warning "allocating zero-element
array".
template <class T, int size = 0> class Array
{
public:
Array() {
if (size) {
new T[size];
}
}
};
void foo() {
Array<int> bar;
}
the new command is guarded by a if(size). So allocating a zero size array is
impossible. It would be really nice if gcc could check for this condition,
also.
Thanks,
Gregor
--
Summary: False positive: allocating zero-element array
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gjasny at web dot de
GCC build triplet: gcc version 4.2.0 20061217 (prerelease) (Debian 4.2-
20061217-1)
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30343