public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug translation/24135] New: nonlocal goto from nested function gets 'undefined symbol' in assembler
@ 2005-09-29 23:48 alexey dot starovoytov at sun dot com
  2005-09-29 23:55 ` [Bug middle-end/24135] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 6+ messages in thread
From: alexey dot starovoytov at sun dot com @ 2005-09-29 23:48 UTC (permalink / raw)
  To: gcc-bugs

The following code compiled with just -O0 generates bad assembler with
undefined label:

int x(int a, int b)
{
  __label__ xlab;
  __label__ xlab2;

  void y(int b)
    {
       switch (b)
        {
          case 1: goto xlab;
          case 2: goto xlab;
        }
    }

  a = a + 2;

  y (b);

 xlab:;
  return a;

 xlab2:;
      a++;
  return a;

}

main (int ac)
{
  int i;
  if ((i=x (1, ac), printf("%d\n",i), i) != 2 + ac)
    abort ();

  exit (0);
}

The assembler failure looks like:
Undefined                       first referenced
 symbol                             in file
.LL9                                /var/tmp//ccLPhTcj.o
ld: fatal: Symbol referencing errors. No output written to a.out

The t04.nested tree already looks bad:
----------------------------------
y (b)
{
  voidD.28 *[3] * D.1136;
  voidD.28 *[3] * D.1138;

  switch (bD.1124)
    {
      case 1: goto <D1127>;
      case 2: goto <D1128>;
      default : goto <D1131>;
    }
  <D1127>:;
  D.1136 = &CHAIN.1D.1135->__nl_goto_bufD.1133;
  __builtin_nonlocal_goto (&<D1132>, D.1136);
  <D1128>:;
  D.1138 = &CHAIN.1D.1135->__nl_goto_bufD.1133;
  __builtin_nonlocal_goto (&<D1137>, D.1138);
  <D1131>:;
}

x (a, b)
{ 
  struct FRAME.x FRAME.0D.1134;
  intD.0 D.1129;
  voidD.28 xlabD.1122 = <<< error >>>;
  voidD.28 xlab2D.1123 = <<< error >>>;
  static voidD.28 yD.1125 (intD.0);
  
  aD.1118 = aD.1118 + 2;
  y (bD.1119) [static-chain: &FRAME.0D.1134];
  goto xlabD.1122;
  <D1137>: [non-local];
  xlabD.1122:;
  D.1129 = aD.1118;
  return D.1129;
  xlab2D.1123:;
  aD.1118 = aD.1118 + 1;
  D.1129 = aD.1118;
  return D.1129;
}
----------------------------------

The line with problems:  __builtin_nonlocal_goto (&<D1132>, D.1136);

The reference to &<D1132> is a reference to non-existent label.
This problem can be reproduced on all 4.0.* versions and 4.1-20050924 as well.
The versions 3.x are ok.

I think all hardware platforms may be affected.

Alex.

-- 
           Summary: nonlocal goto from nested function gets 'undefined
                    symbol' in assembler
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: translation
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexey dot starovoytov at sun dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.*
  GCC host triplet: sparc-sun-solaris2.*
GCC target triplet: sparc-sun-solaris2.*


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-10-03 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24135-7321@http.gcc.gnu.org/bugzilla/>
2005-10-03 16:24 ` [Bug middle-end/24135] [4.0/4.1 Regression] nonlocal goto from nested function gets 'undefined symbol' in assembler janis187 at us dot ibm dot com
2005-10-03 18:58 ` rth at gcc dot gnu dot org
2005-10-03 20:57 ` cvs-commit at gcc dot gnu dot org
2005-10-03 22:02 ` cvs-commit at gcc dot gnu dot org
2005-10-03 22:05 ` rth at gcc dot gnu dot org
2005-09-29 23:48 [Bug translation/24135] New: " alexey dot starovoytov at sun dot com
2005-09-29 23:55 ` [Bug middle-end/24135] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org

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).