This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Problem with class template instantiated with void.
- To: "'egcs-bugs at cygnus dot com'" <egcs-bugs at cygnus dot com>
- Subject: Problem with class template instantiated with void.
- From: "Wegher, Jeff" <JWegher at neonsoft dot com>
- Date: Mon, 30 Nov 1998 18:57:54 -0700
Hi guys,
A little template instantiation problem popped up between 1.1b and the Nov
22 snapshot.
For some reason, it's either attempting to instantiate template members
which aren't used or is doing too much checking of the template members upon
first parse, and thus causes a little problem with smart-pointers
instantiated with void.
For instance:
# line 1"test_bad_void_template.cpp"
template < typename Type>
class Pointer
{
Type* m_pObject;
public:
operator Type* () const { return m_pObject; }
Type& operator * () const { return *m_pObject; }
};
int main()
{
void* p;
Pointer< void> vPtr;
p = vPtr;
return 0;
}
Compiling this code works fine under 1.1b (since the vPtr instance is not
dereferenced) but chokes now with:
% g++ test_bad_void_template.cpp -o test_bad_void_template
test_bad_void_template.cpp: In instantiation of `Pointer<void>':
test_bad_void_template.cpp:15: instantiated from here
test_bad_void_template.cpp:9: forming reference to void
Relevant compiler info is: egcs-2.92.23 sparc-sun-solaris2.5.1, compiled
with --enable-threads --enable-shared
BTW, something didn't change in the standard that says this code is invalid,
did it?
Jeff