While writing some C++ code (compiling with clang, x86_64 linux) I accidentally wrote the following construct:
class Class {
*Class() {}
};
i.e. with a asterisk (*) in front of the constructor name.
Trying a bit more I noticed you can put an arbitrary amount of * in front; and it also works for destructors, i.e.,
class Class {
********Class() {}
********~Class() {}
};
Clang compiles it without any errors or warnings.
GCC however gives the warning
control reaches end of non-void function
which leads me to believe that I am actually declaring a constructor/destructor with return type void* (or void********). And writing any kind of return statement with a value gives an error (as expected):
return nullptr;
return {};
...
Interestingly the generated LLVM IR bitcode correctly contains a void function:
define void @_ZN5ClassC2Ev(%struct.Class* %this) {...}
define void @_ZN5ClassD2Ev(%struct.Class* %this) {...}
Searching for any information on this didn't turn up any results. So my question: Is this standard conform C++ or a bug in the compiler frontends of GCC & Clang? Or maybe some compatibility feature? If correct what is the use case for it.