gcc-3.4.0 fixes
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review
Quoted 6 lines · Mikael Pettersson
This patch fixes three warnings from gcc-3.4.0 in 2.6.6-rc3:
-drivers/char/ftape/: use of cast-as-lvalue(quoted diff) +1
-1if (get_unaligned((__u32*)ptr)) { - ++(__u32*)ptr; + ptr += sizeof(__u32); } else {
Can anyone explain what is the problem with this?
To me it seems pretty ligitimate code - why it was outlawed in gcc 3.4?
Previous code was agnostic to type of ptr, but you code presume ptr
being char pointer (to effectively increment by 4 bytes).
So what all this buzz about?
Quoted 11 lines · Ihar 'Philips' Filipau
Review
Quoted 6 lines · Mikael Pettersson
This patch fixes three warnings from gcc-3.4.0 in 2.6.6-rc3:
-drivers/char/ftape/: use of cast-as-lvalue(quoted diff) +1
-1if (get_unaligned((__u32*)ptr)) { - ++(__u32*)ptr; + ptr += sizeof(__u32); } else {Can anyone explain what is the problem with this?
To me it seems pretty ligitimate code - why it was outlawed in gcc
3.4?
http://es-sun2.fernuni-hagen.de/cgi-bin/info2html?(gcc)Subscripting
The ability to manipulate a cast was always a gcc extension, whether by design or feature I am not sure. The problem is that it breaks C++ templates in a bad way. Here is where the extension is documented for GCC 3.3.3
http://gcc.gnu.org/onlinedocs/gcc-3.3.3/gcc/Lvalues.html
This extension is now obsoleted.
Quoted 2 lines
Previous code was agnostic to type of ptr, but you code presume ptr
being char pointer (to effectively increment by 4 bytes).
Yes, and the previous code assumed that that ptr was not a pointer to a 64 bit value, since dereferencing it on most platforms would then explode. I bet that both assumptions are just as safe ;-) However if you really wanted to be safe then you could do
ptr += sizeof (__32) / sizeof (*ptr);
Again, assuming that we are not using a greater then 4 byte ptr*, since otherwise it would not increment... But personally I think that this is not required.
Cheers,
Paul
Quoted 10 lines · Ihar 'Philips' Filipau
Review
Quoted 6 lines · Mikael Pettersson
This patch fixes three warnings from gcc-3.4.0 in 2.6.6-rc3:
-drivers/char/ftape/: use of cast-as-lvalue(quoted diff) +1
-1if (get_unaligned((__u32*)ptr)) { - ++(__u32*)ptr; + ptr += sizeof(__u32); } else {Can anyone explain what is the problem with this?
To me it seems pretty ligitimate code - why it was outlawed in gcc 3.4?
cast is not a lvalue. ++(__u32*)ptr is nonsense, just like ++4.
Quoted 2 lines
Previous code was agnostic to type of ptr, but you code presume ptr
being char pointer (to effectively increment by 4 bytes).
This would be agnostic too:
ptr = (void*) ((char*)ptr + sizeof(__u32));
--
vda
Quoted 15 lines · Denis Vlasenko
Quoted 11 lines · Ihar 'Philips' Filipau
Quoted 6 lines · Mikael Pettersson
This patch fixes three warnings from gcc-3.4.0 in 2.6.6-rc3:
-drivers/char/ftape/: use of cast-as-lvalueif (get_unaligned((__u32*)ptr)) {(quoted diff) +1
-1- ++(__u32*)ptr; + ptr += sizeof(__u32);} else {Can anyone explain what is the problem with this?
To me it seems pretty ligitimate code - why it was outlawed in gcc 3.4?
Quoted 2 lines
cast is not a lvalue. ++(__u32*)ptr is nonsense, just like ++4.
Yes. I see. C goes in direction of C++.
For me cast in C is always "forget original type and assume this type."
From this standpoint it makes a lot of sense. Is just like
((stuct { char a,b,c,d;})4).a - never tryed it in gcc (3.3 does not accept it), but IIRC was possible on old PC C compilers - Turbo C 2/3 - not sure name/version, but I used it. (Yes! recalled - M$VC/winbase.h use this kind of macros for manipulating bytes/words/dwords/etc)
And in old C classes it was always said that in C you can convert
anything to everything, it just size of types must be the same.
Why not after all?
Quoted 2 lines
ptr = (void*) ((char*)ptr +
sizeof(__u32));
No Nice, But Accepted.
I have just checked my code base - I do not use this feature in any
way ;-)
Signature · 13 lines
Ihar 'Philips' Filipau / with best regards from Saarbruecken.
-- _ _ _
A programmer is a person who passes as an exacting expert |_|*|_|
on the basis of being able to turn out, after innumerable |_|_|*|
punching, an infinite series of incomprehensible answers |*|*|*|
calculated with micrometric precisions from vague
assumptions based on debatable figures taken from inconclusive
documents and carried out on instruments of problematical accuracy
by persons of dubious reliability and questionable mentality for
the avowed purpose of annoying and confounding a hopelessly
defenseless department that was unfortunate enough to ask for the
information in the first place.
-- IEEE Grid newsmagazine