Issue 129675
Summary [clang-tidy] bugprone-throw-keyword-missing on default member initializer: "did you mean 'throw shared_ptr'?"
Labels clang-tidy
Assignees
Reporter N-Dekker
    Using LLVM 19.1.7, I encountered a false positive `bugprone-throw-keyword-missing` from [ITK](https://itk.org)'s [itkExceptionObject.h](https://github.com/InsightSoftwareConsortium/ITK/blob/32a2a6de17ffb7c8319ab38dbe61bd3b7c171f00/Modules/Core/Common/include/itkExceptionObject.h), which can be reproduced as follows:

```cpp
#include <exception>
#include <memory>

class MyException : public std::exception
{
public:
 MyException() = default;
private:
  class NestedData;
 std::shared_ptr<NestedData> m_shared_data{};
};

class Bug : public MyException
{
public:
  Bug()
  {
    // Non-defaulted default constructor.
  }
};

```

Output:

```
warning: suspicious exception object created but not thrown; did you mean 'throw shared_ptr'? [bugprone-throw-keyword-missing]
   10 |   std::shared_ptr<NestedData> m_shared_data{};
      |                                            ^```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to