[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

Domján Dániel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 8 14:46:05 PDT 2022


isuckatcs added a comment.

I've found a strange scenario.

The following conversions are allowed

  double *a[2][3];
  double const * const (*ap)[3] = a; // OK
  double * const (*ap1)[] = a;       // OK since C++20

However if the same conversion is supposed to be performed in a `catch()` statement, it's not happening and the thrown object is not caught.
See it on godbolt <https://godbolt.org/z/sEz8eYeP1>.

Quoteing cppreference <https://en.cppreference.com/w/cpp/language/try_catch>:

  When an exception is thrown by any statement in compound-statement, the exception object of type E is matched against the types of the formal parameters T of each catch-clause in handler-seq, in the order in which the catch clauses are listed. The exception is a match if any of the following is true:
  
  ...
  - T is (possibly cv-qualified) U or const U& (since C++14), and U is a pointer or pointer to member type, and E is also a pointer or pointer to member type that is implicitly convertible to U by one or more of
    - a standard pointer conversion other than one to a private, protected, or ambiguous base class
    - **a qualification conversion**
    - a function pointer conversion (since C++17)
  ...

Checking the quality conversion related part of cppreference <https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions> lists the examples I quoted before as performable conversions.


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

https://reviews.llvm.org/D135495



More information about the cfe-commits mailing list