Hey,

On Tue, 16 Aug 2022, ntysdd via Tinycc-devel wrote:

Sorry, bad format.


 #define G(x) _Generic((x),int*:"int*",void*:"void*")

 int printf(const char*, ...);

 int main()
 {
         int y = 0;
         const char *s = G(1?(void*)(y*0LL):&y);
         printf("%s\n", s);
 }

Fixed in mob.


Ciao,
Michael.


____________________________________________________________________________

 


------------------ Original ------------------
From: "ntysdd" <nty...@qq.com>;
Date: Tue, Aug 16, 2022 08:32 PM
To: "tinycc-devel"<tinycc-devel@nongnu.org>;
Subject: miscompilation for code snippet

TCC gets different result than gcc or clang for code below
&gt;
&gt; #define G(x) _Generic((x),int*:"int*",void*:"void*")
&gt;
&gt; int printf(const char*, ...);
&gt;
&gt; int main()
&gt; {
&gt;         int y = 0;
&gt;         const char *s = G(1?(void*)(y*0LL):&amp;y);
&gt;         printf("%s\n", s);
&gt; }

expected
void*

actual
int*

Similar constructs are used in Linux kernel.

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to