This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15882] New: Check for return type of overloaded operator new too early
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2004 20:41:01 -0000
- Subject: [Bug c++/15882] New: Check for return type of overloaded operator new too early
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I don't know what to say about this, but I'd like to solicit second
opinions -- this fails:
-----------------------
#include <new>
template <bool C, typename T> struct SFINAE;
template <typename T> struct SFINAE<true,T>
{
typedef T type;
};
SFINAE<true, void *>::type
operator new (size_t, int);
template <typename T>
typename SFINAE<T::condition, void *>::type
operator new (size_t, T);
------------------------
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c y.cc
y.cc:14: error: `operator new' must return type `void*'
I believe that the check for the return type is set too early, while
parsing the declaration of the template, not during instantiation. As
is shown in the first overload of the operator, gcc is quite happy
with a somewhat convoluted way to specify a return type of 'void*'.
In the second overload, this may still be possible, if just the type
'T' has an appropriately defined static member condition, or something
else that can be converted to a bool evaluating to 'true'. However, the
fact that we already get the error message before we even try to
instantiate something seems wrong.
W.
--
Summary: Check for return type of overloaded operator new too
early
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15882