https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Erich Eckner from comment #17) > With that, I get a segfault in cpuid(): > > (gdb) run > Starting program: /tmp/a.out > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/lib/libthread_db.so.1". > > Program received signal SIGSEGV, Segmentation fault. > 0x0000555555555191 in cpuid () > (gdb) bt > #0 0x0000555555555191 in cpuid () > #1 0x00005555555551ef in main () > (gdb) > > ... same on x86_64 - maybe, there's a typo, somewhere? Sorry, wrote it without actually trying to compile it, I've swapped the last 2 arguments of cpuid. Use static void cpuid( unsigned int ax, unsigned int cx, unsigned int *p ) { unsigned int flags; __asm __volatile ("movl %%ebx, %%esi\n\t" "cpuid\n\t" "xchgl %%ebx, %%esi" : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3]) : "0" (ax), "2" (cx)); } int main() { unsigned int regs[4]; for (int j=0; j<=18; j++) { int k = j > 10 ? -__INT_MAX__ - 1 + (j - 11) : j; cpuid( k, 0, regs ); __builtin_printf("%d %d ", k, 0); for (int i=0; i<4; i++) { __builtin_printf("%08x ", regs[i]); } __builtin_printf("\n"); cpuid( k, 1, regs ); __builtin_printf("%d %d ", k, 1); for (int i=0; i<4; i++) { __builtin_printf("%08x ", regs[i]); } __builtin_printf("\n"); } return 0; }