http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53586
--- Comment #2 from Paulo Torrens <paulotorrens at gnu dot org> 2012-06-06 18:43:13 UTC --- (In reply to comment #1) > What happens if you use decltype instead of typeof ? template<typename T> auto ptr2bitmap(T *bitmap, int width, int depth = 3) -> decltype(decltype(unsigned char[depth])[width]) *{ return bitmap; }; int main() { void *x; auto a = ptr2bitmap(x, 100); }; test.cpp:2:10: error: expected primary-expression before 'decltype' test.cpp:2:10: error: expected ')' before 'decltype' test.cpp:2:1: error: expected type-specifier before 'decltype' test.cpp:2:1: error: expected initializer before 'decltype' And without decltype and typeof at all: template<typename T> auto ptr2bitmap(T *bitmap, int width, int depth = 3) -> unsigned char[depth][width] *{ return bitmap; }; int main() { void *x; auto a = ptr2bitmap(x, 100); }; test.cpp:2:15: error: use of parameter 'depth' outside function body test.cpp:2:22: error: use of parameter 'width' outside function body test.cpp:2:29: error: expected initializer before '*' token