rupprecht added a comment.

This has already been reverted, but I found a breakage (not a crash) caused by 
this:

  #include <type_traits>
  
  class Base {
   protected:
    int member;
  };
  
  template <typename Parent>
  struct Subclass : public Parent {
    static_assert(std::is_base_of<Base, Parent>::value,
                  "Parent not derived from Base");
    int func() { return Base::member; }
  };
  
  using Impl = Subclass<Base>;
  
  int use() {
    Impl i;
    return i.func();
  }

gcc/msvc both accept this. But clang says:

  <source>:8:29: error: 'member' is a protected member of 'Base'
    int func() { return Base::member; }
                              ^
  <source>:15:12: note: in instantiation of member function 
'Subclass<Base>::func' requested here
    return i.func();
             ^
  <source>:3:7: note: must name member using the type of the current context 
'Subclass<Base>'
    int member;
        ^

A fix is to write `Parent::member` instead of `Base::member`, but I'm wondering 
what the spec actually says about this, and if clang is right to reject it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143840/new/

https://reviews.llvm.org/D143840

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to