* 2.4.10-pre9 min/max raises "const" warnings
@ 2001-09-14 17:55 Alexander Stohr
2001-09-14 18:55 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Stohr @ 2001-09-14 17:55 UTC (permalink / raw)
To: linux-kernel
try this one:
int a, b, c, d;
d = min( a, min( b, c ));
and you will see a gnu c warning about multiple const qualifiers.
(this might depend on the warning level you drive.)
fix it with this code:
#define min(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
(_x < _y) ? (typeof(x)) _x : (typeof(y)) _y; })
simply the last line has changed towards linux kernel patch-2.4.10-pre9 from
ftp.
the same change should apply for the max() macro.
i am yet not sure if the used "? :" operator set does qualify as
a left-value. maybe this could be another important reason why
return types here should stay identical to input types.
regards AlexS.
PS: i am not subscribed to this list.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: 2.4.10-pre9 min/max raises "const" warnings
2001-09-14 17:55 2.4.10-pre9 min/max raises "const" warnings Alexander Stohr
@ 2001-09-14 18:55 ` Andreas Schwab
2001-09-14 22:55 ` J . A . Magallon
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2001-09-14 18:55 UTC (permalink / raw)
To: Alexander Stohr; +Cc: linux-kernel
Alexander Stohr <AlexanderS@ati.com> writes:
|> i am yet not sure if the used "? :" operator set does qualify as
|> a left-value.
For Standard C it isn't, but for GNU C it is.
Andreas.
--
Andreas Schwab "And now for something
Andreas.Schwab@suse.de completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2.4.10-pre9 min/max raises "const" warnings
2001-09-14 18:55 ` Andreas Schwab
@ 2001-09-14 22:55 ` J . A . Magallon
0 siblings, 0 replies; 3+ messages in thread
From: J . A . Magallon @ 2001-09-14 22:55 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Alexander Stohr, linux-kernel
On 20010914 Andreas Schwab wrote:
>Alexander Stohr <AlexanderS@ati.com> writes:
>
>|> i am yet not sure if the used "? :" operator set does qualify as
>|> a left-value.
>
>For Standard C it isn't, but for GNU C it is.
>
Perhaps it is nonsense, but, as the kernel already uses gcc-specific features,
the gcc folks could extend to C th '<?' and '>?' operators from C++, so
#define max(a,b) (a >? b)
#define min(a,b) (a <? b)
It works at least since 2.95.2. gcc3 warns about signs in -Wall mode.
--
J.A. Magallon # Let the source be with you...
mailto:jamagallon@able.es
Mandrake Linux release 8.1 (Cooker) for i586
Linux werewolf 2.4.9-ac10 #1 SMP Sat Sep 8 02:27:41 CEST 2001 i686
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-09-14 22:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-14 17:55 2.4.10-pre9 min/max raises "const" warnings Alexander Stohr
2001-09-14 18:55 ` Andreas Schwab
2001-09-14 22:55 ` J . A . Magallon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox