Re: [PATCH][2.6.6-rc3] gcc-3.4.0 fixes

From: Ihar 'Philips' Filipau
Date: Thu Apr 29 2004 - 16:42:52 EST


Denis Vlasenko wrote:
On Thursday 29 April 2004 12:30, Ihar 'Philips' Filipau wrote:

Mikael Pettersson wrote:

This patch fixes three warnings from gcc-3.4.0 in 2.6.6-rc3:
- drivers/char/ftape/: use of cast-as-lvalue
if (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.


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?


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 ;-)

--
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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/