NetBSD Problem Report #43491

From www@NetBSD.org  Sun Jun 20 16:23:57 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id ACD8163BA4A
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 20 Jun 2010 16:23:57 +0000 (UTC)
Message-Id: <20100620162356.E0C9063BA47@www.NetBSD.org>
Date: Sun, 20 Jun 2010 16:23:56 +0000 (UTC)
From: dan@archlinux.org
Reply-To: dan@archlinux.org
To: gnats-bugs@NetBSD.org
Subject: libfetch compile warnings with gcc in ftp.c
X-Send-Pr-Version: www-1.0

>Number:         43491
>Category:       pkg
>Synopsis:       libfetch compile warnings with gcc in ftp.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 20 16:25:00 +0000 2010
>Closed-Date:    Fri May 12 08:35:39 +0000 2023
>Last-Modified:  Fri May 12 08:35:39 +0000 2023
>Originator:     Dan McGee
>Release:        N/A
>Organization:
Arch Linux
>Environment:
Linux galway 2.6.34-ARCH #1 SMP PREEMPT Sat Jun 19 00:07:49 CEST 2010 x86_64 Intel(R) Core(TM)2 Quad CPU Q9400 @ 2.66GHz GenuineIntel GNU/Linux
>Description:
Compiling libfetch under gcc (GCC) 4.5.0 20100610 (prerelease) on Linux yields the following warnings, which are easily fixable. This was with 2.32 but it has existed for a while.

$ make
  compile    ftp.o
ftp.c: In function ‘ftp_transfer’:
ftp.c:917:45: warning: array subscript is above array bounds
ftp.c:917:33: warning: array subscript is above array bounds
ftp.c:917:21: warning: array subscript is above array bounds
ftp.c:917:9: warning: array subscript is above array bounds
ftp.c:916:43: warning: array subscript is above array bounds
ftp.c:916:31: warning: array subscript is above array bounds
ftp.c:916:20: warning: array subscript is above array bounds
ftp.c:916:9: warning: array subscript is above array bounds


>How-To-Repeat:
Compile libfetch 2.32 from source; not sure if you need a newer version of GCC to see these warnings.
>Fix:


Index: libfetch/files/ftp.c
===================================================================
RCS file: /cvsroot/pkgsrc/net/libfetch/files/ftp.c,v
retrieving revision 1.35
diff -u -r1.35 ftp.c
--- libfetch/files/ftp.c        21 Mar 2010 16:48:43 -0000      1.35
+++ libfetch/files/ftp.c        20 Jun 2010 16:18:00 -0000
@@ -907,7 +907,7 @@
                                        goto ouch;
                        }
                        if (e != FTP_OK) {
-                               ap = (char *)&u.sin6.sin6_addr;
+                               ap = (char *)&u.sin6.sin6_addr.s6_addr;
                                e = ftp_cmd(conn,
                                    "LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\n",
                                    6, 16,


>Release-Note:

>Audit-Trail:
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/43491: libfetch compile warnings with gcc in ftp.c
Date: Sun, 20 Jun 2010 19:02:32 +0200

 On Sun, Jun 20, 2010 at 04:25:00PM +0000, dan@archlinux.org wrote:
 > Compiling libfetch under gcc (GCC) 4.5.0 20100610 (prerelease) on Linux
 > yields the following warnings, which are easily fixable. This was with
 > 2.32 but it has existed for a while.

 This warnings look bogus. I'm not really inclined to hack around this.
 Essentially, sin6_addr is a union and it shouldn't complain as long as
 it stays within the size of the union and if the patch helps, it
 certainly should have done that in the original case already.

 Joerg

From: Dan McGee <dan@archlinux.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/43491: libfetch compile warnings with gcc in ftp.c
Date: Sun, 20 Jun 2010 12:15:29 -0500

 On Sun, Jun 20, 2010 at 12:05 PM, Joerg Sonnenberger
 <joerg@britannica.bec.de> wrote:
 > The following reply was made to PR pkg/43491; it has been noted by GNATS.
 >
 > From: Joerg Sonnenberger <joerg@britannica.bec.de>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: pkg/43491: libfetch compile warnings with gcc in ftp.c
 > Date: Sun, 20 Jun 2010 19:02:32 +0200
 >
 > =C2=A0On Sun, Jun 20, 2010 at 04:25:00PM +0000, dan@archlinux.org wrote:
 > =C2=A0> Compiling libfetch under gcc (GCC) 4.5.0 20100610 (prerelease) on=
  Linux
 > =C2=A0> yields the following warnings, which are easily fixable. This was=
  with
 > =C2=A0> 2.32 but it has existed for a while.
 >
 > =C2=A0This warnings look bogus. I'm not really inclined to hack around th=
 is.
 > =C2=A0Essentially, sin6_addr is a union and it shouldn't complain as long=
  as
 > =C2=A0it stays within the size of the union and if the patch helps, it
 > =C2=A0certainly should have done that in the original case already.

 I agree it looks bogus, considering the fix. It only happens on x86_64
 vs. i686 as well, which is interesting. Version 2.12 of glibc on both
 systems.

 Does it hurt to point at the right internal element though? It doesn't
 seem like a huge hack to me, and you refer to s6_addr elsewhere in
 ftp.c.

 Just for reference, here is the declaration in the header files:

 /* IPv6 address */
 struct in6_addr
   {
     union
       {
     uint8_t __u6_addr8[16];
 #if defined __USE_MISC || defined __USE_GNU
     uint16_t __u6_addr16[8];
     uint32_t __u6_addr32[4];
 #endif
       } __in6_u;
 #define s6_addr         __in6_u.__u6_addr8
 #if defined __USE_MISC || defined __USE_GNU
 # define s6_addr16      __in6_u.__u6_addr16
 # define s6_addr32      __in6_u.__u6_addr32
 #endif
   };

 /* Ditto, for IPv6.  */
 struct sockaddr_in6
   {
     __SOCKADDR_COMMON (sin6_);
     in_port_t sin6_port;    /* Transport layer port # */
     uint32_t sin6_flowinfo; /* IPv6 flow information */
     struct in6_addr sin6_addr;  /* IPv6 address */
     uint32_t sin6_scope_id; /* IPv6 scope-id */
   };

 -Dan

From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/43491: libfetch compile warnings with gcc in ftp.c
Date: Sun, 20 Jun 2010 22:02:41 +0000

 On Sun, Jun 20, 2010 at 05:20:04PM +0000, Dan McGee wrote:
  >  I agree it looks bogus, considering the fix. It only happens on x86_64
  >  vs. i686 as well, which is interesting. Version 2.12 of glibc on both
  >  systems.
  >  
  >  Does it hurt to point at the right internal element though? It doesn't
  >  seem like a huge hack to me, and you refer to s6_addr elsewhere in
  >  ftp.c.

 It probably doesn't; but there's some chance that this only hides the
 warnings but does not avoid whatever issue is leading gcc to think
 wrong things. You should definitely report this as a gcc bug...

 (Since it looks to be warning on exactly the upper half of the
 address, I'm wondering if it's got wrong types or sizes somewhere.)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 12 May 2023 08:35:39 +0000
State-Changed-Why:
issue in prerelease version of gcc 4.5, assume no longer relevant


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: gnats-precook-prs,v 1.4 2018/12/21 14:20:20 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.