0x8000-0000 added a comment.

Here is a minimal example that shows the problem:

  #include <memory>
  
  template<typename SomeValue>
  struct DoGooder
  {
      DoGooder(void* accessor, SomeValue value)
      {
      }
  
  };
  
  struct Bingus
  {
      static constexpr auto someRandomConstant = 99;
  };
  
  template<typename Foo>
  struct HardWorker
  {
      HardWorker()
      {
          const DoGooder anInstanceOf{nullptr, Foo::someRandomConstant};
      }
  };
  
  struct TheContainer
  {
      std::unique_ptr<HardWorker<Bingus>> m_theOtherInstance;
  };

Example run:

  $ /opt/clang10/bin/clang-tidy 
-checks="-*,cppcoreguidelines-const-correctness" -header-filter=".*" 
reproconst.cpp -- -std=c++17 -Wall
  54 warnings generated.
  reproconst.cpp:22:9: warning: variable 'anInstanceOf' of type '<dependent 
type>' can be declared 'const' [cppcoreguidelines-const-correctness]
          const DoGooder anInstanceOf{nullptr, Foo::someRandomConstant};
          ^
                         const
  Suppressed 53 warnings (53 in non-user code).
  Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943



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

Reply via email to