compiler-explorer icon indicating copy to clipboard operation
compiler-explorer copied to clipboard

[BUG]: Calling `clock()` SIGSEGVs on armv8

Open chris0e3 opened this issue 1 month ago • 0 comments

Describe the bug

The following C++ code compiles but fails when executed on any armv8 (clang/gcc any version) server. Also gettimeofday, timespec_get, clock_gettime return junk values. No problem on x86-64.

#include <cstdio>
#include <time.h>
int main () { return std::printf("now: %ld\n", long(clock())); }

Output is usually Program returned: 139 Program terminated with signal: SIGSEGV though sometimes result is 135. [Similar C code fails the same.]

Steps to reproduce

  1. Visit godbolt.org
  2. Select armv8-a clang (trunk), C++
  3. Select Output… ✓ Execute the code
  4. Enter above program

Expected behavior

Something like the following in the Output panel:

ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 10
now: 3603

Reproduction link

https://godbolt.org/z/z3hEv85e7

Screenshots

Not applicable

Operating System

No response

Browser version

No response

chris0e3 avatar Nov 11 '25 21:11 chris0e3