From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93365 invoked by alias); 20 May 2015 19:54:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 93350 invoked by uid 48); 20 May 2015 19:54:02 -0000 From: "steven.deller at ois dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66226] New: Incorrect code generation ppc, later assignment causes calling argument corruption Date: Wed, 20 May 2015 19:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: steven.deller at ois dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg01689.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66226 Bug ID: 66226 Summary: Incorrect code generation ppc, later assignment causes calling argument corruption Product: gcc Version: 4.9.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: steven.deller at ois dot com Target Milestone: --- Created attachment 35581 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35581&action=edit Interim file In the attached code, a simple assignment "rp = res" after the call to getaddrinfo causes the arguments to getaddrinfo to be invalid, most likely the hints argument, since making that argument NULL also allows the compiled code to execute successfully. An assignment following a call should not cause different behavior within the call. This only fails on the PowerPC compiler (I only have tested it on AIX). It fails for versions 4.7.3, 4.8.3 and this reported 4.9.3 version. The gcc compiler is the version supplied from AdaCore with the GNAT products. I do not have access to the build information for the compiler. Regards, Steven Deller 410-757-6924 tga.c source: #include #include #include int main(int argc, char **argv) { struct addrinfo *res; struct addrinfo hints; int rc; struct addrinfo *rp; hints.ai_family = AF_INET; /* IPv4 only */ hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = 0; hints.ai_protocol = 0; hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; rc = getaddrinfo("aix7", NULL, &hints, &res); // if hints is "NULL", runs fine rp = res; // rc=11 with this in. Comment out and rc=0. printf ("rc=%d\n", rc); return 0; } output from "gcc -v -save-temps tga.c" compilation: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/lto-wrapper Target: powerpc-ibm-aix7.1.0.0 Configured with: ../src/configure --enable-languages=ada,c --with-gnu-as --with-gnu-ld --with-dwarf2 --disable-shared --disable-build-poststage1-with-cxx --disable-libsanitizer --disable-libcilkrts --with-bugurl=URL:mailto:report@adacore.com --disable-nls --without-libiconv-prefix --disable-libmudflap --disable-libstdcxx-pch --disable-libada --enable-checking=release --enable-multilib --disable-plugin --with-mpfr=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/mpfr/install --with-gmp=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/gmp/install --with-mpc=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix-linux/mpc/install --with-build-time-tools=/sully.a/gnatmail/sandbox/gnat-7.3.1/ppc-aix/gcc/build/buildtools/bin --prefix=/usr/local/gnat --target=powerpc-ibm-aix7.1.0.0 --host=powerpc-ibm-aix7.1.0.0 --build=i686-pc-linux-gnu Thread model: aix gcc version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/cc1 -E -quiet -v -iprefix /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/ tga.c -fpch-preprocess -o tga.i ignoring nonexistent directory "/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../../powerpc-ibm-aix7.1.0.0/include" ignoring duplicate directory "/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include" ignoring duplicate directory "/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include-fixed" ignoring nonexistent directory "/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../../powerpc-ibm-aix7.1.0.0/include" #include "..." search starts here: #include <...> search starts here: /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/include-fixed /usr/local/include /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/../../include /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/cc1 -fpreprocessed tga.i -quiet -dumpbase tga.c -auxbase tga -version -o tga.s GNU C (GCC) version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118) (powerpc-ibm-aix7.1.0.0) compiled by GNU C version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768 GNU C (GCC) version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118) (powerpc-ibm-aix7.1.0.0) compiled by GNU C version 4.9.3 20141101 for GNAT Pro 7.3.1 (20150118), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768 Compiler executable checksum: 1afb14c19ac4a4577644783d23418153 COLLECT_GCC_OPTIONS='-v' '-save-temps' /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/as -v -u -mpwr4 -many -o tga.o tga.s GNU assembler version 2.24.51 (powerpc-ibm-aix7.1.0.0) using BFD version (GNU Binutils) 2.24.51.20140908 COMPILER_PATH=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/ LIBRARY_PATH=/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/:/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../libexec/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect /lib/crt0.o /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/crtcxa.o -L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3 -L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc -L/toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/../../.. tga.o /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/libgcc.a -lc /toolchain/compilers/GNAT-7.3.1/ppc_6xx-aix_5.3/bin/../lib/gcc/powerpc-ibm-aix7.1.0.0/4.9.3/libgcc.a