Time to string exact
On my system, I am getting a segmentation fault. The issue is that all these are evaluated to false
https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/server/TracyPrint.cpp#L262
https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/server/TracyPrint.cpp#L285
https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/server/TracyPrint.cpp#L297
https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/server/TracyPrint.cpp#L306
and then the errors occurs in
https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/server/TracyPrint.cpp#L72-L91
Here is a minimal reproducer
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <limits>
void ko(int64_t _ns)
{
std::cout << "KO" << std::endl;
std::cout << _ns << std::endl;
uint64_t ns;
if( _ns < 0 )
{
ns = -_ns;
}
else
{
ns = _ns;
}
std::cout << ns << std::endl;
std::cout << 1000ll << std::endl;
std::cout << (ns >= 1000ll) << std::endl;
}
void ok(int64_t _ns)
{
std::cout << "OK" << std::endl;
std::cout << _ns << std::endl;
uint64_t ns;
if( _ns == std::numeric_limits<int64_t>::min() )
{
ns = -(_ns + 1) + 1;
}
else if( _ns < 0 )
{
ns = -_ns;
}
else
{
ns = _ns;
}
std::cout << ns << std::endl;
std::cout << 1000ll << std::endl;
std::cout << (ns >= 1000ll) << std::endl;
}
int main() {
ko(-9223372036854775808ULL);
ok(-9223372036854775808ULL);
return 0;
}
Then I can reproduce the issue with g++ with -O2 or -O3 but not clang++
$ g++ -O3 main.cpp && ./a.out
KO
-9223372036854775808
9223372036854775808
1000
0
OK
-9223372036854775808
9223372036854775808
1000
1
$ g++ -O1 main.cpp && ./a.out
KO
-9223372036854775808
9223372036854775808
1000
1
OK
-9223372036854775808
9223372036854775808
1000
1
$ clang++ -O3 main.cpp && ./a.out
KO
-9223372036854775808
9223372036854775808
1000
1
OK
-9223372036854775808
9223372036854775808
1000
1
The way I understand the issue is that -_ns does not fit in int64_t even though it fits in uint64_t.
So the idea is to first convert to uint64_t and then do +1.
My gcc version is
$ g++ --version
g++ (GCC) 15.1.1 20250425
$ uname -a
Linux Precision5570 6.14.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 29 Apr 2025 09:23:13 +0000 x86_64 GNU/Linux