№1:
#ifdef USING_VOLATILE
#define VOLATILE volatile
#else
#define VOLATILE
#endif
void f(const int&) {}
void f(const volatile int&) {}
using T = const VOLATILE int;
int main() { T i = 0; f(static_cast<T&&>(i)); }
$ g++ -xc++ -std=c++14 -pedantic-errors -o/dev/null -DUSING_VOLATILE test.cxx
test.cxx: In function 'int main()':
test.cxx:12:25: error: invalid initialization of non-const reference of type 'const volatile int&' from an rvalue of type 'T {aka const volatile int}'
int main() { T i = 0; f(static_cast<T&&>(i)); }
^~~~~~~~~~~~~~~~~~~
test.cxx:8:6: note: initializing argument 1 of 'void f(const volatile int&)'
void f(const volatile int&) {}
^
#ifndef DIRECT_ALIASING
#define ALIASED trait_t<As...>
#else
#define ALIASED typename trait<As...>::type
#endif
template<typename T, typename... As> struct trait_impl { using type = T; };
template<typename... As> struct trait :trait_impl<As...> {};
template<typename T, typename... As> using trait_t = typename trait<T,As...>::type;
template<typename... As> using trait_type = ALIASED;
int main() { return trait_type<int,unsigned,long>(0); }
$ g++ -xc++ -std=c++14 -pedantic-errors -o/dev/null test.cxx
test.cxx:2:31: error: pack expansion argument for non-pack parameter 'T' of alias template 'template<class T, class ... As> using trait_t = typename trait<T, As ...>::type'
#define ALIASED trait_t<As...>
^
test.cxx:10:45: note: in expansion of macro 'ALIASED'
template<typename... As> using trait_type = ALIASED;
^~~~~~~
test.cxx:9:10: note: declared here
template<typename T, typename... As> using trait_t = typename trait<T,As...>::type;
^~~~~~~~
test.cxx: In function 'int main()':
test.cxx:12:21: error: 'trait_type' was not declared in this scope
int main() { return trait_type<int,unsigned,long>(0); }
^~~~~~~~~~
test.cxx:12:32: error: expected primary-expression before 'int'
int main() { return trait_type<int,unsigned,long>(0); }
^~~
test.cxx:12:32: error: expected ';' before 'int'
test.cxx:12:35: error: expected unqualified-id before ',' token
int main() { return trait_type<int,unsigned,long>(0); }
^
test.cxx:12:36: error: expected unqualified-id before 'unsigned'
int main() { return trait_type<int,unsigned,long>(0); }
^~~~~~~~
Два бага в компиляторе за один день - это слишком толсто. Упорот ли я?