language: C++11 (gcc-4.7.2)
date: 748 days 12 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <type_traits>
 
template<class Derived>
struct Base{
  typedef Base<Derived> MyType;
 
  Base(){
    typedef char ERROR_You_screwed_up[ std::is_base_of<MyType,Derived>::value ? 1 : -1 ];
  }
};
 
class ConcreteDerived : public Base<int>{
};
 
int main(){
  ConcreteDerived cd;
 
}
prog.cpp: In constructor 'Base<Derived>::Base() [with Derived = int]':
prog.cpp:12:41:   instantiated from here
prog.cpp:8:88: error: creating array with negative size ('-0x000000001')