https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118831
--- Comment #12 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to jcldc13 from comment #10) > (In reply to Jakub Jelinek from comment #6) > > Note, it is wrong even on x86_64. For varargs functions, %rax needs to be > > number of floating point arguments in the ABI, but if called through K&R or > > Fortran unspecified arguments function type, nothing fills in %rax, so it > > will be some random value.(In reply to Jakub Jelinek from comment #6) > > Note, it is wrong even on x86_64. For varargs functions, %rax needs to be > > number of floating point arguments in the ABI, but if called through K&R or > > Fortran unspecified arguments function type, nothing fills in %rax, so it > > will be some random value. > > You can run by yourself my test case on x86 computer, and you'll always get, > pretty sure, "hello world" stored in "myval" variable. No random value, > except from aarch64 computer (at least from a Mac ARM) Jakub already explained this. This happens to work on x86_64 because of its application binary interface (aka the argument passing conventions). aarch64 has a different convention, and there it does not work. > Well, you are all gcc experts, and I am just a programmer. But how to > explain I have never got an issue on x86 if you say that I should get random > values ... ? See above, this "works" on x86, but not on aarch64. If you want your code to work on other architectures, you will have to rewrite the C functions as non-variadic (without the ...) and then call the right one, preferably using C interoperability. You can check for interface errors if you use -flto.