[cfe-dev] undefbehavior.ExitInDtor

Mario Lang mlang at delysid.org
Mon Feb 2 15:16:20 PST 2015


Hi.

The List of potential checkers[1] posted recently contains this item,
which looked like a low hanging fruit, ideal for getting my feet wet
with matchers:

   Undefined behavior: std::exit() is called to end the program during
   the destruction of an object with static storage duration.

   Source: C++11 3.6.1p4.

#include <cstdlib>

class A {
public:
  ~A() {
    std::exit(1); // warn
  }
};

I took this as an exercise, and was very surprised to see how easy this
was to do, and how little time it took to get done, given that my
experience with the AST prior to yesterday was virtually zero.

I have two questions:

1. What would be an approriate name / category for this check?
2. Is it worth submitting?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DestructorExitCheck.patch
Type: text/x-diff
Size: 5246 bytes
Desc: Check for exit() during destruction of static storage duration objects
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150203/37fb3768/attachment.patch>
-------------- next part --------------

[1] http://clang-analyzer.llvm.org/potential_checkers.html

-- 
CYa,
  ⡍⠁⠗⠊⠕


More information about the cfe-dev mailing list