> On 2026-07-14 15:49:01 +0200, Vincent Lefevre wrote:
> > On 2026-07-14 10:51:47 +0000, Alexy via Tinycc-devel wrote:
> > > 
> > > No erros no warnings. Just compile and work
> > > 
> > > #include <stdio.h>
> > > 
> > > int main()
> > > {
> > >     char* t[5] = {"999"};
> > > 
> > >     t[0] = "123456";
> > >     t[4] = "X";
> > >     t[15] = "abcdef";
> > >     t[25] = "MNO";
> > >     t[35] = "C";
> > > 
> > >     printf( "%s\n%s\n%s\n%s\n", *t, t[4], t[15], t[25] );
> > > }
> > 
> > This is undefined behavior. The compiler is not required to warn
> > (and cannot always warn). With GCC, the issue is detected by using
> > "-fsanitize=undefined".
> 
> Note that GCC also has -Warray-bounds, but it is unreliable:
> 
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
> 
> So I wouldn't expect tcc to be better, in addition to the fact
> that tcc is designed to be a light and fast compiler.
> 

One TCC specific addition: compiling this example with "tcc -b"
detects the first invalid access at runtime.

TCC currently has no equivalent static array bounds warning. This
particular constant index case could be considered for a narrowly
scoped diagnostic enhancement.

Mounir IDRASSI




_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to