This is a libtcc issue: gcc and clang behave the same way.
// libtcc mangles casts of hard-coded pointer values// Run with: tcc
-run tcc-libtcc-address-bug.c// The 2nd call to 'test()' produces
incorrect results, and often crashes with SIGSEGV.//// tcc version
0.9.28rc 2025-12-15 mob@85694274 (AArch64 Linux)// uname -a => Linux
penguin 6.6.88-08646-g082267a5c5ac #1 SMP PREEMPT Fri, 29 Aug 2025
06:42:16 -0700 aarch64 GNU/Linux#include <stdio.h>#include
"libtcc.h"#pragma comment(lib, "tcc")void test(char *prog, int *x){
char C[1024]; sprintf(C, prog, x); TCCState *s = tcc_new();
tcc_set_output_type(s, TCC_OUTPUT_MEMORY); if
(!tcc_compile_string(s, C) && !tcc_relocate(s)) { int
(*deref)() = tcc_get_symbol(s, "deref"); printf("%s --> ", C);
if (deref) printf("%d", deref()); else printf("Couldn't
find it!"); printf("\n"); } tcc_delete(s);}int main(){
setbuf(stdout, NULL); int x = 42; test("int deref() { int *addr
= (int *)%p; return *addr; }", &x); test("int deref() { return
*(int *)%p; }", &x); return 0;}
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel