Compile 
==== begin of test.cpp ====
int main()
{
 const unsigned nElementCount = 0;
 int *piArray = nElementCount ? new int[nElementCount] : 0;
 return 0;
}
==== end of test.cpp ====

Compiler displays a warning even though new operator is never executed: 
test.cpp: In function 'int main()':
test.cpp:4: warning: allocating zero-element array

It does not depend on optimization.


-- 
           Summary: False warning: allocating zero-element array
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oder at eleks dot lviv dot ua
 GCC build triplet: x86
  GCC host triplet: x86
GCC target triplet: x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33914

Reply via email to