mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Horst von Brand <vonbrand@inf.utfsm.cl>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: {put,get}_user() side effects
Date: Wed, 07 Apr 2004 00:53:26 +0200	[thread overview]
Message-ID: <je3c7gyazd.fsf@sykes.suse.de> (raw)
In-Reply-To: <200404062053.i36KrC3Y005111@eeyore.valparaiso.cl> (Horst von Brand's message of "Tue, 06 Apr 2004 16:53:11 -0400")

Horst von Brand <vonbrand@inf.utfsm.cl> writes:

> Geert Uytterhoeven <geert@linux-m68k.org> said:
>> On Tue, 6 Apr 2004, Andi Kleen wrote:
>> > Geert Uytterhoeven <geert@linux-m68k.org> writes:
>> > > On most (all?) architectures {get,put}_user() has side effects:
>> > >
>> > > #define put_user(x,ptr)                                                 \
>> > >   __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
>> >
>> > Neither typeof not sizeof are supposed to have side effects. If your
>> > compiler generates them that's a compiler bug.
>
>> From a simple compile test, you seem to be right... Weird, since it does
>> expand to 3 times 'pIndex++', but pIndex is incremented only once.
>
> Better check with a C language lawyer. Maybe gcc gets it wrong, or it is
> undefined

It's not undefined, the standard explicitly says that the argument of
sizeof is not evaluated (unless its type is a VLA).  I can't remember gcc
ever getting that wrong.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2004-04-06 22:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1HVGV-1Wl-21@gated-at.bofh.it>
2004-04-06 11:32 ` Andi Kleen
2004-04-06 11:46   ` Geert Uytterhoeven
2004-04-06 20:53     ` Horst von Brand
2004-04-06 22:53       ` Andreas Schwab [this message]
2004-04-06 11:50   ` Xavier Bestel
2004-04-06 12:17     ` Wichert Akkerman
2004-04-06 14:28   ` Xavier Bestel
2004-04-06 15:30     ` Kevin P. Fleming
2004-04-06 15:47       ` Xavier Bestel
2004-04-06 10:03 Geert Uytterhoeven
2004-04-06 10:10 ` Russell King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=je3c7gyazd.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vonbrand@inf.utfsm.cl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®