This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33124] C++ frontend should not warn about new a[0] in template context
- From: "mec at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2007 19:31:45 -0000
- Subject: [Bug c++/33124] C++ frontend should not warn about new a[0] in template context
- References: <bug-33124-1313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from mec at google dot com 2007-08-20 19:31 -------
"new T[0]" looks like defined behavior to me.
[expr.new] 5.3.4 -7-
When the value of the expression in a direct-new-declarator is zero, the
allocation function is called to allocate an array with no elements. The
pointer returend by the new-expression is non-null. [Note: if the library
allocation function is called, the pointer returned is distinct from the the
pointer to any other object.]
===
cp/init.c even quotes that section in a comment before giving the warning.
cp/init.c goes on to say "However, that is not generally useful, so we issue a
warning". new T[0] is valid C++ and here is a useful case.
--
mec at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mec at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33124