tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] sizeof("string literal") is very wrong ~ On ARM or Ap


From: Vincent Lefevre
Subject: Re: [Tinycc-devel] sizeof("string literal") is very wrong ~ On ARM or Apple Silicon
Date: Fri, 5 Aug 2022 10:50:57 +0200
User-agent: Mutt/2.2.6+34 (76e93dd3) vl-149028 (2022-07-31)

On 2022-08-05 09:22:42 +0200, Karl Yerkes wrote:
> That did not help. It seems that there is a problem on ARM or Apple
> Silicon, specifically:
> 
> #include <stdio.h>
> int main() {
>   printf("%%lu: %lu\n", sizeof("this is a string"));
>   printf("%%d: %d\n", sizeof("this is a string"));
>   printf("%%zu: %zu\n", sizeof("this is a string"));
> }

In any case, this code has undefined behavior. Just use %zu,
nothing else.

That said, if size_t has the same size as unsigned long, the first
line should have probably been correct in practice, and

> $ tcc tcc-string-literal-sizeof.c
> FIXME: handle reloc type 9 at 1052 [0x60000155c032] to 1050

may be an issue with tcc (though this is conform to the standard).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]