http://llvm.org/bugs/show_bug.cgi?id=7408

Douglas Gregor <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Douglas Gregor <[email protected]> 2010-07-14 19:44:38 CDT 
---
(In reply to comment #1)
> Checking [class.virtual]p5 clearly requires Covariant<T> to be complete.  I
> can't seem to find anything in the standard which specifies precisely when it
> should be instantiated, though.

GCC is waiting until the class is fully defined before it checks for covariant
return types, as you can see with this modified version of the example:


struct BaseReturn {
};

template <typename T> struct Base{
  virtual BaseReturn* GetEdges(long n) { return 0;}
};

template <typename T> struct Derived;

template<typename T>
struct Covariant {
  typename Derived<T>::LaterTypedef x;
};

template <typename T>
struct Derived : Base<T> {
  virtual Covariant<T>* GetEdges(long n) {
    return 0;
  }
 typedef char LaterTypedef;

  typedef T *blah;
};

Derived<long&> derived;

where the diagnostics for the "pointer to reference" error come before the
"invalid covariant return type" error, even though the code for the "pointer to
reference" error comes after the virtual function.

It seems to me like GCC is being overly generous, and that a user can't rely on
code that makes use of members defined later in the class. Closing as INVALID,
but I'm willing to entertain arguments that this is a real bug.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to