[Bug c/30343] New: False positive: allocating zero-element array
gjasny at web dot de
gcc-bugzilla@gcc.gnu.org
Mon Jan 1 18:47:00 GMT 2007
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
More information about the Gcc-bugs
mailing list