public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Wolfgang Kuehn <wolfgang.kuehn@kristensen.de>
Cc: Richard Henderson <rth@redhat.com>, gcc@gcc.gnu.org
Subject: Re: register variable is clobbered by passing parameter to a function
Date: Tue, 16 Mar 2004 12:30:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.58.0403161322580.26679@wotan.suse.de> (raw)
In-Reply-To: <001301c40b4c$d27ddb20$406510ac@B1WS064>

Hi,

On Tue, 16 Mar 2004, Wolfgang Kuehn wrote:

> I know, what I do.

You believe you know what you do, but ...

> The register keyword is not obligatory for the compiler, he can use a

... this, and ...

> This behaviour says in conclusion, that you never has to use the register
> keyword, because the compiler makes what he want.

... this indicates that in fact you don't.  You confuse the "register" 
keyword (which is an official ISO C keyword, but merely a hint to the 
compiler where to place the variable, ignored mostly by GCC) with register 
variables (those with an added 'asm ("d0")') which is an GCC extension.

> a.. Global register variables reserve registers throughout the program. This
> may be useful in programs such as programming language interpreters which
> have a couple of global variables that are accessed very often.

This says nothing about local register variables, like you used.

In essence local register variables don't contain the value you think they 
do.  They really represent the register itself at the point of the 
reference, i.e. depend on how the compiler choose to layout the code 
surrounding that reference.  In particular they don't prevent other values 
from being placed into the same register (in difference to global register 
vars).


Ciao,
Michael.

  reply	other threads:[~2004-03-16 12:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-15 10:54 Wolfgang Kuehn
2004-03-15 22:51 ` Richard Henderson
2004-03-16 11:50   ` Wolfgang Kuehn
2004-03-16 12:30     ` Michael Matz [this message]
2004-03-16 12:39       ` Michael Matz
2004-03-16 12:43       ` Dave Korn
2004-03-16 13:00         ` Ian Lance Taylor
2004-03-16 13:21           ` Dave Korn
2004-03-16 10:20 ` Dave Korn
2004-03-16 14:18 Wolfgang Kuehn
2004-03-16 14:47 ` Ian Lance Taylor

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=Pine.LNX.4.58.0403161322580.26679@wotan.suse.de \
    --to=matz@suse.de \
    --cc=gcc@gcc.gnu.org \
    --cc=rth@redhat.com \
    --cc=wolfgang.kuehn@kristensen.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).