From patchwork Tue May 26 23:14:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 6932 Received: (qmail 109479 invoked by alias); 26 May 2015 23:14:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109468 invoked by uid 89); 26 May 2015 23:14:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Message-ID: <1432682074.28747.28.camel@ubuntu-sellcey> Subject: Re: [PATCH] Fix strict-aliasing warning in resolv/res_hconf.c From: Steve Ellcey Reply-To: To: Roland McGrath CC: Florian Weimer , Andreas Schwab , "Paul Eggert" , Date: Tue, 26 May 2015 16:14:34 -0700 In-Reply-To: <20150526215601.197BC2C39FC@topped-with-meat.com> References: <5bfa6373-3817-4d31-a5ee-a8676e79b723@BAMAIL02.ba.imgtec.org> <555BB55E.3050304@cs.ucla.edu> <1432075989.16668.62.camel@ubuntu-sellcey> <555BC19B.90001@cs.ucla.edu> <1432077972.16668.65.camel@ubuntu-sellcey> <20150519235817.9516F2C3A73@topped-with-meat.com> <555C3E0B.2040404@redhat.com> <555C48F0.2030208@redhat.com> <1432139240.16668.77.camel@ubuntu-sellcey> <555F1430.5050301@redhat.com> <1432666068.28747.19.camel@ubuntu-sellcey> <5564C0AC.40708@redhat.com> <20150526215601.197BC2C39FC@topped-with-meat.com> MIME-Version: 1.0 On Tue, 2015-05-26 at 14:56 -0700, Roland McGrath wrote: > As I said before, adding the #include in that public header is not right. In that case the two solutions I see are to compile res_hconf.c with -fno-strict-aliasing or to put DIAG_PUSH_NEEDS_COMMENT, etc. macros around the two casts in res_hconf.c to turn off the strict aliasing warnings. Using -fno-strict-aliasing seems safer as I do not know (based on my own knowledge) that the casts in question do not cause any problems when compiled with strict aliasing. How about this patch? Steve Ellcey sellcey@imgtec.com 2015-05-26 Steve Ellcey * resolv/Makefile: Use -fno-strict-aliasing when compiling res_hconf.c. diff --git a/resolv/Makefile b/resolv/Makefile index f62eea4..453046c 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -85,7 +85,12 @@ CPPFLAGS += -Dgethostbyname=res_gethostbyname \ ifeq (yes,$(have-ssp)) CFLAGS-libresolv += -fstack-protector endif -CFLAGS-res_hconf.c = -fexceptions + +# The casts of cur_ifr->ifr_addr and cur_ifr->ifr_netmask in +# _res_hconf_reorder_addrs to pointers to sockaddr_in type break +# GCC's strict aliasing rules and cause GCC 6 to generate a +# warning unless -fno-strict-aliasing is used. +CFLAGS-res_hconf.c = -fexceptions -fno-strict-aliasing # The BIND code elicits some harmless warnings. +cflags += -Wno-strict-prototypes -Wno-write-strings