No investigation, no right to speak
jiang@jiang:~/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
);
}
jiang@jiang:~/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",
^
jiang@jiang:~/test$ ./a.out
3
jiang@jiang:~/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
);
}
jiang@jiang:~/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",
^
jiang@jiang:~/test$ ./a.out
-1 -1
jiang@jiang:~/test$
于 2014年06月21日 00:00, [email protected] 写道:
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
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel