Bug 45955 - FAIL: gcc.dg/initpri1.c (test for excess errors)
Summary: FAIL: gcc.dg/initpri1.c (test for excess errors)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-09 16:06 UTC by John David Anglin
Modified: 2010-10-11 14:03 UTC (History)
1 user (show)

See Also:
Host: hppa2.0w-hp-hpux11.11
Target: hppa2.0w-hp-hpux11.11
Build: hppa2.0w-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2010-10-09 16:06:43 UTC
Executing on host: /test/gnu/gcc/objdir/gcc/xgcc -B/test/gnu/gcc/objdir/gcc/ /te
st/gnu/gcc/gcc/gcc/testsuite/gcc.dg/initpri1.c    -ansi -pedantic-errors  -lm   
-o ./initpri1.exe    (timeout = 300)
WARNING: program timed out.
compiler exited with status 1
FAIL: gcc.dg/initpri1.c (test for excess errors)

Running under gdb, I see:

Program received signal SIGINT, Interrupt.
0x01478e68 in build_cdtor (ctor_p=1 '\001', cdtors=0x400c9108)
    at ../../gcc/gcc/ipa.c:1490
1490	      while (i < len);
(gdb) bt
#0  0x01478e68 in build_cdtor (ctor_p=1 '\001', cdtors=0x400c9108)
    at ../../gcc/gcc/ipa.c:1490
#1  0x01479384 in build_cdtor_fns () at ../../gcc/gcc/ipa.c:1565
#2  0x0147962c in ipa_cdtor_merge () at ../../gcc/gcc/ipa.c:1594
#3  0x00ca6da0 in execute_one_pass (pass=0x4001ca4c)
    at ../../gcc/gcc/passes.c:1562
#4  0x00ca8058 in execute_ipa_pass_list (pass=0x4001ca4c)
    at ../../gcc/gcc/passes.c:1929
#5  0x013ee044 in ipa_passes () at ../../gcc/gcc/cgraphunit.c:1734
#6  0x013ee1a8 in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1769
#7  0x013eb62c in cgraph_finalize_compilation_unit ()
    at ../../gcc/gcc/cgraphunit.c:1020
#8  0x000c262c in c_write_global_declarations ()
    at ../../gcc/gcc/c-decl.c:9821
#9  0x00e2c434 in compile_file () at ../../gcc/gcc/toplev.c:946
#10 0x00e30508 in do_compile () at ../../gcc/gcc/toplev.c:2374
#11 0x00e30694 in toplev_main (argc=19, argv=0x7eff05e4)
    at ../../gcc/gcc/toplev.c:2415
#12 0x00373f34 in main (argc=19, argv=0x7eff05e4) at ../../gcc/gcc/main.c:36

There's a thinko in this code:

      /* Find the next batch of constructors/destructors with the same
         initialization priority.  */
      for (;i < j; i++)
        {
          tree call;
          fn = VEC_index (tree, cdtors, i);
          call = build_call_expr (fn, 0);
          if (ctor_p)
            DECL_STATIC_CONSTRUCTOR (fn) = 0;
          else
            DECL_STATIC_DESTRUCTOR (fn) = 0;
          /* We do not want to optimize away pure/const calls here.
             When optimizing, these should be already removed, when not
             optimizing, we want user to be able to breakpoint in them.  */
          TREE_SIDE_EFFECTS (call) = 1;
          append_to_statement_list (call, &body);
        }
      while (i < len);
Comment 1 Richard Biener 2010-10-09 16:21:39 UTC
(In reply to comment #0)
> Executing on host: /test/gnu/gcc/objdir/gcc/xgcc -B/test/gnu/gcc/objdir/gcc/
> /te
> st/gnu/gcc/gcc/gcc/testsuite/gcc.dg/initpri1.c    -ansi -pedantic-errors  -lm   
> -o ./initpri1.exe    (timeout = 300)
> WARNING: program timed out.
> compiler exited with status 1
> FAIL: gcc.dg/initpri1.c (test for excess errors)
> 
> Running under gdb, I see:
> 
> Program received signal SIGINT, Interrupt.
> 0x01478e68 in build_cdtor (ctor_p=1 '\001', cdtors=0x400c9108)
>     at ../../gcc/gcc/ipa.c:1490
> 1490          while (i < len);
> (gdb) bt
> #0  0x01478e68 in build_cdtor (ctor_p=1 '\001', cdtors=0x400c9108)
>     at ../../gcc/gcc/ipa.c:1490
> #1  0x01479384 in build_cdtor_fns () at ../../gcc/gcc/ipa.c:1565
> #2  0x0147962c in ipa_cdtor_merge () at ../../gcc/gcc/ipa.c:1594
> #3  0x00ca6da0 in execute_one_pass (pass=0x4001ca4c)
>     at ../../gcc/gcc/passes.c:1562
> #4  0x00ca8058 in execute_ipa_pass_list (pass=0x4001ca4c)
>     at ../../gcc/gcc/passes.c:1929
> #5  0x013ee044 in ipa_passes () at ../../gcc/gcc/cgraphunit.c:1734
> #6  0x013ee1a8 in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1769
> #7  0x013eb62c in cgraph_finalize_compilation_unit ()
>     at ../../gcc/gcc/cgraphunit.c:1020
> #8  0x000c262c in c_write_global_declarations ()
>     at ../../gcc/gcc/c-decl.c:9821
> #9  0x00e2c434 in compile_file () at ../../gcc/gcc/toplev.c:946
> #10 0x00e30508 in do_compile () at ../../gcc/gcc/toplev.c:2374
> #11 0x00e30694 in toplev_main (argc=19, argv=0x7eff05e4)
>     at ../../gcc/gcc/toplev.c:2415
> #12 0x00373f34 in main (argc=19, argv=0x7eff05e4) at ../../gcc/gcc/main.c:36
> 
> There's a thinko in this code:
> 
>       /* Find the next batch of constructors/destructors with the same
>          initialization priority.  */
>       for (;i < j; i++)
>         {
>           tree call;
>           fn = VEC_index (tree, cdtors, i);
>           call = build_call_expr (fn, 0);
>           if (ctor_p)
>             DECL_STATIC_CONSTRUCTOR (fn) = 0;
>           else
>             DECL_STATIC_DESTRUCTOR (fn) = 0;
>           /* We do not want to optimize away pure/const calls here.
>              When optimizing, these should be already removed, when not
>              optimizing, we want user to be able to breakpoint in them.  */
>           TREE_SIDE_EFFECTS (call) = 1;
>           append_to_statement_list (call, &body);
>         }
>       while (i < len);

Looks like a funny cut&pasto.  Just remove the last while (i < len) line
which actually is an endless loop.
Comment 2 John David Anglin 2010-10-11 14:02:08 UTC
Author: danglin
Date: Mon Oct 11 14:02:03 2010
New Revision: 165308

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165308
Log:
	PR middle-end/45955
	* ipa.c (build_cdtor): Delete endless loop.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa.c
Comment 3 John David Anglin 2010-10-11 14:03:19 UTC
Fixed.