------- Comment #1 from jakub at gcc dot gnu dot org  2009-03-18 08:56 -------
Created an attachment (id=17483)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17483&action=view)
gcc44-pr39485.patch

Self inflicted pain I'd say, if you don't want something in register, don't use
a register keyword.  That said, the following patch does that for you.
In 4.3 the reason why the above testcase had v stored in memory, not in
register, has been just that it has been used in multiple basic blocks and
global allocation wasn't performed.
If you use a simpler testcase like:
struct S
{
  int x;
  int method ();
};

int
S::method ()
{
  return x + 5;
}

int
main ()
{
  register S v;
  v.x = 0;
  return v.x + 5;
}
then even g++ 4.3 and earlier will allocate v in a register and so you won't be
able to do v.method () in the debugger (though, with the attached patch you
can).
With the patch:
struct S
{
  int x;
};

int
main ()
{
  register int v;
  int i;
  v = 0;
  for (i = 0; i < 13; ++i)
    v += i;
  --v;
  return v + 5;
}
will still use a register for v, but that is definitely fine.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39485

Reply via email to