Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
langcpp
#include <csetjmp>
#include <iostream>


static jmp_buf env;


struct Counter {
  static int Instances;
  Counter() { ++Instances; }
  ~Counter() { --Instances; }
};


int Counter::Instances = 0;


void f() {
  Counter c;
  std::cout << "f(): Instances: " << Counter::Instances << std::endl;
  std::longjmp(env, 1);
}

int main() {
  std::cout << "Before setjmp(): Instances: " << Counter::Instances << std::endl;
  if (setjmp(env) == 0) {
    f();
  } else {
    std::cout << "From longjmp(): Instances: " << Counter::Instances << std::endl;
  }
  std::cout << "After longjmp(): Instances: " << Counter::Instances << std::endl;
}

...

Tool

Version

Checker

Description

 PRQA QA-C++

 
Include Page
PRQA QA-C++_vV
PRQA QA-C++_vV

Secondary Analysis

 

Related Vulnerabilities

...