public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Dave Korn" <dk@artimi.com>
To: <gcc@gcc.gnu.org>
Subject: RE: register variable is clobbered by passing parameter to a function
Date: Tue, 16 Mar 2004 10:20:00 -0000	[thread overview]
Message-ID: <NUTMEG6YHkidcDjoYAP00000149@NUTMEG.CAM.ARTIMI.COM> (raw)
In-Reply-To: <002301c40a7b$ee521b30$406510ac@B1WS064>

 

> -----Original Message-----
> From: gcc-owner On Behalf Of Wolfgang Kuehn
> Sent: 15 March 2004 10:55

> When I declare an often used variable as register, the 
> variable is modified after calling a function.
> Example-code:
> 
> register  char often_used_variable asm ("r16"); char foo;
> void function1 (char p1, char p2, char p3, char p4, char p5) {   };

> I could not found anything about this behaviour in the 
> gcc-online-docs.

  It's right there in the bit about asm ("register"):

Docs
 -> Extensions to the C Language Family
   -> Variables in Specified Registers
     -> Specifying Registers for Local Variables

[
http://gcc.gnu.org/onlinedocs/gcc-3.3.3/gcc/Local-Reg-Vars.html#Local%20Reg%
20Vars ]

" Defining such a register variable does not reserve the register; it
remains available for other uses in places "

" This option does not guarantee that GCC will generate code that has this
variable in the register you specify at all times. You may not code an
explicit reference to this register in an asm statement and assume it will
always refer to this variable. "

> K&R says, the compiler can ignore the keyword. 

That's the register keyword itself; do not confuse it with the asm register
attribute, which is an entirely separate (gcc-specific) feature.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

  parent reply	other threads:[~2004-03-16 10:20 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
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 [this message]
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=NUTMEG6YHkidcDjoYAP00000149@NUTMEG.CAM.ARTIMI.COM \
    --to=dk@artimi.com \
    --cc=gcc@gcc.gnu.org \
    /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).