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: "gdr at cs dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2007 23:23:31 -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 #3 from gdr at cs dot tamu dot edu 2007-08-20 23:23 -------
Subject: Re: C++ frontend should not warn about new a[0] in template context
"mec at google dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| "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.
Thanks for reminding me that the construct is NOT undefined beahviour.
That, I think, also supports the case that we should NOT disable
the warning for template instantiations.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33124