simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

address `bugprone-exception-escape` clang-tidy warning in `Macro` copy constructor

Open firewave opened this issue 4 months ago • 3 comments

Encountered in #421.

/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_pair.h:295:17: error: an exception may be thrown in function 'pair' which should not throw exceptions [bugprone-exception-escape,-warnings-as-errors]
  295 |       constexpr pair(pair&&) = default;         ///< Move constructor
      |                 ^
/home/runner/work/simplecpp/simplecpp/simplecpp.cpp:1747:29: note: frame #0: unhandled exception of type 'simplecpp::Macro::Error' may be thrown in function 'parseDefine' here
 1747 |                             throw Error(tok->location, "In definition of '" + nameTokDef->str() + "': Missing opening parenthesis for __VA_OPT__");
      |                             ^
/home/runner/work/simplecpp/simplecpp/simplecpp.cpp:1508:21: note: frame #1: function 'operator=' calls function 'parseDefine' here
 1508 |                     parseDefine(other.nameTokDef);
      |                     ^
/home/runner/work/simplecpp/simplecpp/simplecpp.cpp:1495:19: note: frame #2: function 'Macro' calls function 'operator=' here
 1495 |             *this = other;
      |                   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_pair.h:295:17: note: frame #3: function 'pair' calls function 'Macro' here
  295 |       constexpr pair(pair&&) = default;         ///< Move constructor
      |                 ^
``

firewave avatar Sep 09 '25 10:09 firewave

An attempt at this was posted in #493.

firewave avatar Sep 09 '25 10:09 firewave

clang-tidy-22 is currently no longer reporting this because the handling of system headers changed.

firewave avatar Sep 09 '25 21:09 firewave

This is a part of #424.

firewave avatar Nov 13 '25 23:11 firewave