Debug GCC


SUBMITTED BY: haxonic

DATE: May 11, 2017, 10:24 a.m.

UPDATED: May 11, 2017, 10:25 a.m.

FORMAT: Text only

SIZE: 690 Bytes

HITS: 536

  1. /// Does this code expose a GCC bug?
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5. #define SHOW_BUG
  6. template <typename Derived>
  7. struct Base
  8. {
  9. template <typename T>
  10. #ifdef SHOW_BUG
  11. void push_back(T& t)
  12. #else
  13. void push_back2(T& t)
  14. #endif
  15. {
  16. static_cast<Derived*>(this)->push_back(t);
  17. }
  18. };
  19. struct P : public Base<P>, protected vector<int>
  20. {
  21. friend class Base<P>;
  22. vector<int> v;
  23. };
  24. int main()
  25. {
  26. int i=10;
  27. P p;
  28. #ifdef SHOW_BUG
  29. p.push_back(i);
  30. #else
  31. p.push_back2(i);
  32. #endif
  33. return 0;
  34. }

comments powered by Disqus