Bug 67031 - avr-gcc internal compiler error: segmentation fault in push_reload, at reload.c
Summary: avr-gcc internal compiler error: segmentation fault in push_reload, at reload.c
Status: RESOLVED DUPLICATE of bug 71873
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2015-07-27 19:46 UTC by Dima Kogan
Modified: 2016-08-22 10:18 UTC (History)
3 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail: 5.2.1
Last reconfirmed: 2016-01-29 00:00:00


Attachments
Minimized source to show the failure (185 bytes, text/plain)
2015-07-27 19:46 UTC, Dima Kogan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dima Kogan 2015-07-27 19:46:36 UTC
Created attachment 36072 [details]
Minimized source to show the failure

Hi. I'm seeing an internal compiler error when building AVR code:

    dima@shorty:$ avr-gcc --std=gnu99 -O3 -mmcu=atxmega16e5 -c tst.c -o bleh.o

    tst.c: In function 'func2':
    tst.c:15:5: warning: implicit declaration of function 'sscanf' [-Wimplicit-function-declaration]
         sscanf(p1, "", &e, &i, &h, &g, &f);
         ^
    tst.c:15:5: warning: incompatible implicit declaration of built-in function 'sscanf' [enabled by default]
    tst.c:15:5: warning: passing argument 1 of 'sscanf' makes pointer from integer without a cast [enabled by default]
    tst.c:15:5: note: expected 'const char *' but argument is of type 'int'
    tst.c:17:5: warning: passing argument 1 of 'func2' makes integer from pointer without a cast [enabled by default]
         func2(j);
         ^
    tst.c:14:5: note: expected 'int' but argument is of type 'int *'
     int func2(int p1) {
         ^
    tst.c: In function 'func':
    tst.c:24:9: warning: passing argument 1 of 'func2' makes integer from pointer without a cast [enabled by default]
             func2(a.ppp);
             ^
    tst.c:14:5: note: expected 'int' but argument is of type 'int *'
     int func2(int p1) {
         ^
    tst.c:26:1: internal compiler error: in push_reload, at reload.c:1360
     }
     ^
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <http://gcc.gnu.org/bugs.html> for instructions.


I'm including minimized source to demo this. The compiler I'm using is whatever is in Debian/unstable now:


    dima@shorty:$ dpkg -l gcc-avr

    ii  gcc-avr                                     1:4.8.1+Atmel3.4.5-1       amd64                      GNU C compiler (cross compiler for avr)



    dima@shorty:$ avr-gcc --verbose --version

    Using built-in specs.
    COLLECT_GCC=/usr/bin/avr-gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.8.1/lto-wrapper
    avr-gcc (GCC) 4.8.1
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


    Target: avr
    Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr
    Thread model: single
    gcc version 4.8.1 (GCC) 
    COLLECT_GCC_OPTIONS='-v' '--version'
     /usr/lib/gcc/avr/4.8.1/cc1 -quiet -v help-dummy -quiet -dumpbase help-dummy -auxbase help-dummy -version --version -o /tmp/cceJxgRU.s
    GNU C (GCC) version 4.8.1 (avr)
            compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.3
    warning: MPFR header version 3.1.2-p11 differs from library version 3.1.2-p3.
    warning: MPC header version 1.0.3 differs from library version 1.0.2.
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    COLLECT_GCC_OPTIONS='-v' '--version'
     /usr/lib/gcc/avr/4.8.1/../../../avr/bin/as --version -o /tmp/ccBrSnpW.o /tmp/cceJxgRU.s
    GNU assembler (GNU Binutils) 2.24
    Copyright 2013 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or later.
    This program has absolutely no warranty.
    This assembler was configured for a target of `avr'.
    COMPILER_PATH=/usr/lib/gcc/avr/4.8.1/:/usr/lib/gcc/avr/4.8.1/:/usr/lib/gcc/avr/:/usr/lib/gcc/avr/4.8.1/:/usr/lib/gcc/avr/:/usr/lib/gcc/avr/4.8.1/../../../avr/bin/
    LIBRARY_PATH=/usr/lib/gcc/avr/4.8.1/:/usr/lib/gcc/avr/4.8.1/../../../avr/lib/
    COLLECT_GCC_OPTIONS='-v' '--version'
     /usr/lib/gcc/avr/4.8.1/collect2 --version -L/usr/lib/gcc/avr/4.8.1 -L/usr/lib/gcc/avr/4.8.1/../../../avr/lib /tmp/ccBrSnpW.o --start-group -lgcc -lm -lc --end-group
    collect2 version 4.8.1
    /usr/lib/gcc/avr/4.8.1/../../../avr/bin/ld --version -L/usr/lib/gcc/avr/4.8.1 -L/usr/lib/gcc/avr/4.8.1/../../../avr/lib /tmp/ccBrSnpW.o --start-group -lgcc -lm -lc --end-group
    GNU ld (GNU Binutils) 2.24
    Copyright 2013 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later version.
    This program has absolutely no warranty.


Thanks!
Comment 1 Senthil Kumar Selvaraj 2015-09-01 11:41:28 UTC
Confirmed on gcc 5.2
Comment 2 Georg-Johann Lay 2016-01-29 22:17:13 UTC
Confirmed with 5.2.1 on mingw32 and

$ avr-gcc source.c -S -O3 -mmcu=atmega8

Also tried to reduce even more and to get it closer to sensible C but the ICE remains:

avr-gcc foo.c -S -Wall -O3 -mmcu=atmega8 -save-temps
foo.c: In function 'func':
foo.c:23:1: internal compiler error: in push_reload, at reload.c:1380
 }
 ^

foo.c:23:1: internal compiler error: Segmentation fault



extern int sscanf (const char*, const char*, ...);

typedef struct {
    int iii;
    char ppp[50];
} S;

extern S a;
extern int b, c, e, g, h, i;

void func2(char *p1) {
    sscanf(p1, "%d %d %d %d", &e, &i, &h, &g);
    char j[30];
    func2(j);
}

void func(void) {
    int d = (int)func;
    while (c < d) {
        b = 23;
        func2(a.ppp);
    }
}
Comment 3 Senthil Kumar Selvaraj 2016-08-22 10:18:48 UTC
Confirmed that a local backport of fix for 71873 to 5.2 fixes this. Unfortunately, maintainers did not approve backporting patch for 71873.

*** This bug has been marked as a duplicate of bug 71873 ***