mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
These were due to several functions occurring that would have the same TRAP key. By making the functions static or wrapping the defining class in an anonymous namespace the TRAP keys will differ from each other.
45 lines
559 B
C++
45 lines
559 B
C++
namespace staticlocals {
|
|
|
|
static int g() {
|
|
return 1;
|
|
}
|
|
|
|
int h() {
|
|
return 1;
|
|
}
|
|
|
|
static void f() {
|
|
static int i = g(), j = h();
|
|
static int k = g();
|
|
;
|
|
}
|
|
|
|
constexpr int addOne(int x) {
|
|
return x + 1;
|
|
}
|
|
|
|
struct C {
|
|
constexpr C() { }
|
|
};
|
|
|
|
void f2() {
|
|
constexpr int two = 2;
|
|
static int i = addOne(two);
|
|
static int j = addOne(2);
|
|
static C c{};
|
|
}
|
|
|
|
template<typename T>
|
|
struct Sizeof {
|
|
enum sizeof_enum { value = sizeof(T) };
|
|
};
|
|
|
|
template<typename T>
|
|
void f3() {
|
|
static int i = Sizeof<T>::value;
|
|
}
|
|
|
|
template void f3<int>();
|
|
|
|
}
|