Open
Description
Bugzilla Link | 26685 |
Version | trunk |
OS | All |
Attachments | A more detailed testcase |
Reporter | LLVM Bugzilla Contributor |
CC | @DougGregor,@hfinkel |
Extended Description
Hello!
Simple code:
template <typename T> structtest { typedefvoid(* type)(T); }; typedefvoidfoo_t() const; typedef test<foo_t>::type func_t;
We've got a function type with cv-qualifier-seq acquires the properties of a function pointer, although it's prohibited by Standard. This behavior occurs in the entire range of compilers.
Do I understand right that func_t (in this case) is invalid type, and it shouldn't be compiled?
So we can use it to bypass the restrictions and create a pointer to cv-qualified function:
template <typename F> structcreate_pointer { typedefvoidfunc_t(F); template <typename X> structextract { typedef X type; }; template <typename X> structextract<void(X)> { typedef X type; }; typedeftypename extract<func_t>::type type; }; intmain() { create_pointer<void() const>::type p = 0; }