tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Tinycc-devel Digest, Vol 134, Issue 15


From: jiang
Subject: Re: [Tinycc-devel] Tinycc-devel Digest, Vol 134, Issue 15
Date: Sat, 21 Jun 2014 10:46:32 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

No investigation, no right to speak

address@hidden:~/test$ cat c3.c
int main(){
/*
struct { unsigned a:9, b:7, c:5; } s;
s.a = s.b = s.c = 3;
printf("%d / %d / %d\n", s.a, s.b, s.c);
*/
struct sbf1 {
int f1 : 3;
int : 2;
int f2 : 1;
int : 0;
int f3 : 5;
int f4 : 7;
unsigned int f5 : 7;
} st1;
st1.f1
// = st1.f2
=3;
printf(" %d \n",
st1.f1
// ,st1.f2
);

}
address@hidden:~/test$ gcc c3.c
c3.c: In function 'main':
c3.c:19:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
printf(" %d \n",
^
address@hidden:~/test$ ./a.out
3
address@hidden:~/test$ cat c3.c
int main(){
/*
struct { unsigned a:9, b:7, c:5; } s;
s.a = s.b = s.c = 3;
printf("%d / %d / %d\n", s.a, s.b, s.c);
*/
struct sbf1 {
int f1 : 3;
int : 2;
int f2 : 1;
int : 0;
int f3 : 5;
int f4 : 7;
unsigned int f5 : 7;
} st1;
st1.f1
= st1.f2
=3;
printf(" %d %d \n",
st1.f1
,st1.f2
);

}
address@hidden:~/test$ gcc c3.c
c3.c: In function 'main':
c3.c:18:5: warning: overflow in implicit constant conversion [-Woverflow]
=3;
^
c3.c:19:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
printf(" %d %d \n",
^
address@hidden:~/test$ ./a.out
-1 -1
address@hidden:~/test$




于 2014年06月21日 00:00, address@hidden 写道:
I see now that must be intentional, but that's also very dangerous.

It looks like you are trying to reproduce a gcc bug, why not make that optional? Perhaps proposing a compatibility mode if it would be a useful
thing to have.

Even if its sensible, you should really control what garbage data you are throwing out from that format specifier. Why not generate a random
value to Emmit? That would seem safer for a large number of reasons.

I should point out I don't know what problem you are trying to solve, this just strikes me as very dodgy code, especially when it seems you are purposefully break working code, to implement a bug. That surely effects everyone using tcc.


On 20/06/2014 11:08, Aidan Dodds wrote:

On 20/06/2014 06:58, jiang wrote:
printf("%d %d %d %d %d\n",
+ st1.f2, st1.f3, st1.f4, st1.f5);

Am i being stupid, or do you specify 5 format specifiers with only 4 arguments?!

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




reply via email to

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