[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#395057: Regression: Even with -O0 -g, gcc 4.1 optimizes a goto away and I cannot debug



Package: gcc
Version 4.1.1-11


In the following sample code, gcc does not create enough
debugging information to let gdb break in lines 27, 30, 33, 36.

This makes debugging the main() function extremely painful.
This is a regression from gcc 2.95 and gcc 3.3, both of which
let gdb set a breakpoint on those lines.

The ability to debug such code is very important to me, since
I usually write my C functions with some cleanup code
after a 'failure' label in the style below.




    1	int f1(void)			/* this "succeeds", i.e. returns 1 */
    2	{
    3	    return 1;
    4	}
    5	
    6	int f2(void)			/* this "succeeds", i.e. returns 1 */
    7	{
    8	    return 1;
    9	}
   10	
   11	int f3(void)			/* this "fails", i.e. returns 0 */
   12	{
   13	    return 0;
   14	}
   15	
   16	int f4(void)			/* this "succeeds", i.e. returns 1 */
   17	{
   18	    return 1;
   19	}
   20	
   21	
   22	int main(int argc, char *argv[])
   23	{
   24	    int c;
   25	
   26	    if (!f1())
   27		goto failure;
   28	
   29	    if (!f2())
   30		goto failure;
   31	
   32	    if (!f3())
   33		goto failure;
   34	
   35	    if (!f4())
   36		goto failure;
   37	
   38	 success:
   39	    return 0;
   40	
   41	 failure:
   42	    return 1;
   43	}


-- 
Claus Fischer <claus.fischer@clausfischer.com>
http://www.clausfischer.com/



Reply to: