Re: Invalid C++ or bug in GCC 4.8
On 2013-06-27 02:46, marcel.loose@googlemail.com wrote:
I was quite unhappy to find out that code I've written years ago
suddenly fails to compile with the latest GCC (4.8). It compiles
without warning (with -Wall and -Wextra) with GCC 4.7.3 as well as
with Clang 3.2.
Below is a completely stripped down version of the code. Is this
illegal C++ code, or is this a bug in GCC 4.8?
The code looks invalid to me, see below why.
<code>
template <typename Signature, typename TypeId> class ObjectFactory;
template<typename Base , typename TypeId>
class ObjectFactory<Base (), TypeId> { };
struct Abstract { virtual ~Abstract() = 0; };
struct Concrete : Abstract { };
typedef ObjectFactory< Abstract(), int> MyFactory;
</code>
When compiling with GCC 4.8 I get the following error:
Eabstract-class-type.cc:10:33: error: ?type name? declared as
function returning an abstract class type
typedef ObjectFactory< Abstract(), int> MyFactory;
The error looks appropriate to me. According to 10.4 [class.abstract],
p3:
"An abstract class shall not be used as a parameter type, as a
function return type, [..]"
This is clearly violated here.
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]