From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109176 invoked by alias); 8 Sep 2016 12:30:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 109167 invoked by uid 89); 8 Sep 2016 12:30:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1165, ASan X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Sep 2016 12:30:40 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2340F6AEB; Thu, 8 Sep 2016 12:30:39 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-204-22.brq.redhat.com [10.40.204.22]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u88CUaL2028632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Sep 2016 08:30:37 -0400 Subject: Re: Make max_align_t respect _Float128 [version 2] To: Bernd Schmidt , Paul Eggert , Mark Wielaard References: <3bb7530e-fff4-6030-a87e-1654d55d1e45@redhat.com> <531b9447-2f95-0714-dfc9-6b419efe1ab9@cs.ucla.edu> <20160907115226.GA26109@gnu.wildebeest.org> Cc: Joseph Myers , gcc-patches@gcc.gnu.org From: Florian Weimer Message-ID: Date: Thu, 08 Sep 2016 12:34:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg00440.txt.bz2 On 09/08/2016 02:26 PM, Bernd Schmidt wrote: > On 09/08/2016 01:21 AM, Paul Eggert wrote: > >> Sure, attached. On Fedora 24 x86-64 (GCC 6.1.1 20160621, valgrind >> 3.11.0), when I compile with "gcc -O2 flexouch.c" and run with "valgrind >> ./a.out", valgrind complains "Invalid read of size 2". This is because >> GCC compiles "p->d[0] == 2 && p->d[1] == 3" into "cmpw $770, 8(%rax); >> sete %al", which loads the uninitialized byte p->d[1] simultaneously >> with the initialized byte p->d[0]. > > Interesting. That optimization doesn't really depend on d being a > flexible array, so you can also reproduce a (different) valgrind warning > with the following: > > #include > #include > > struct s { int x; char d[2]; }; > > __attribute__((noinline,noclone)) void foo (struct s *p) > { > p->d[0] = 1; > } > > int > main (void) > { > struct s *p = malloc (sizeof *p); > foo (p); > return p->d[0] == 2 && p->d[1] == 3; > } Very interesting. So the ASan failure reported for gnulib fts and this valgrind issue have separate causes (ASan does not care about undefined memory). Thanks, Florian