Hi,
2014-08-03 18:33 GMT+02:00 Arthur O'Dwyer <[email protected]>: > Does this reject valid C++ code involving templates? I.e., is there > any wording in the Standard that says this kind of code *can* be > rejected, or are these declarations expected to compile quietly? > > No, it doesn't, the following code isn't rejected by the clang after applying my patch: 1 2 struct C 3 { 4 typedef C type; 5 virtual void foo() = 0; 6 }; 7 8 template<class T> 9 struct X 10 { 11 typename T::type mytype(); 12 }; It's hard to reject that as, AFAIK, we can look into dependent type at this point (but I'm not sure of that). > I don't see anything wrong with returning an instance of an abstract > type, in principle. The type system shouldn't care about that sort of > thing. > > The standard states that "An abstract class shall not be used as a parameter type, as a function return type, or as the type of an explicit conversion" (found this in January 2012 draft, class.abstract $10.4.3) This patch is the easiest way to fix the problem. Probably, I could try to fix it other way, but then I would need to hunt for some special cases, e.g: 1 struct A { 2 virtual int f() = 0; 3 }; 4 5 struct C : A 6 { 7 virtual int f() { return 5; } 8 }; 9 10 struct B { 11 A f() { C a; return a;} 12 }; 13 14 int main() 15 { 16 B b; 17 b.f(); 18 return 0; 19 } Br, Robert Matusewicz
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
