From patchwork Wed Jun 7 09:40:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 20821 Received: (qmail 22161 invoked by alias); 7 Jun 2017 09:41:07 -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 21336 invoked by uid 89); 7 Jun 2017 09:41:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:3918 X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B3BF09F72B Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B3BF09F72B Subject: Re: [PATCH] Dynamic growable arrays for internal use To: Stefan Liebler References: <37f01ed4-1443-8585-42cb-1b7759416ee7@linux.vnet.ibm.com> Cc: libc-alpha@sourceware.org From: Florian Weimer Message-ID: <5308ddfb-a125-e4f6-8615-3148e350bdd6@redhat.com> Date: Wed, 7 Jun 2017 11:40:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <37f01ed4-1443-8585-42cb-1b7759416ee7@linux.vnet.ibm.com> On 06/06/2017 05:30 PM, Stefan Liebler wrote: > Hi Florian, > > I get the following warning / werror with gcc 4.8.5 on s390x: > gcc tst-dynarray.c -O3 -c ... -o /malloc/tst-dynarray.o > In file included from tst-dynarray.c:50:0: > tst-dynarray.c: In function ‘do_test’: > ../support/check.h:51:8: error: ‘result.length’ may be used > uninitialized in this function [-Werror=maybe-uninitialized] > if (expr) \ > ^ > tst-dynarray.c:377:23: note: ‘result.length’ was declared here > struct long_array result; > ^ > In file included from tst-dynarray.c:50:0: > ../support/check.h:51:8: error: ‘result.array’ may be used uninitialized > in this function [-Werror=maybe-uninitialized] > if (expr) \ > ^ > tst-dynarray.c:377:23: note: ‘result.array’ was declared here > struct long_array result; > ^ > cc1: all warnings being treated as errors > > > Have you seen those warnings on other architectures, too? I could reproduce it with -O3 on s390x. I have not tried it with other architectures, but it is a generic problem with TEST_VERIFY_EXIT which is not really related to the dynarray code. I propose the attached patch to fix it. Thanks, Florian support: Expose TEST_VERIFY_EXIT behavior to GCC optimizers Previously, the implementation would conditionally exit based on the status argument, which GCC did not know about. This leads to false uninitialized variable warnings when data is accessed after a TEST_VERIFY_EXIT failure (from code which would never execute). 2017-06-07 Florian Weimer Expose TEST_VERIFY_EXIT process termination to GCC optimizers. * support/support_test_verify_impl.c (support_test_verify_exit_impl): Split from support_test_verify_impl. * support/check.h (TEST_VERIFY): Drop status argument from support_test_verify_impl call. (TEST_VERIFY_EXIT): Call support_test_verify_exit_impl. (support_test_verify_impl): Remove status argument. (support_test_verify_exit_impl): Declare. diff --git a/support/check.h b/support/check.h index 1d244a3..bdcd129 100644 --- a/support/check.h +++ b/support/check.h @@ -51,7 +51,7 @@ __BEGIN_DECLS if (expr) \ ; \ else \ - support_test_verify_impl (-1, __FILE__, __LINE__, #expr); \ + support_test_verify_impl (__FILE__, __LINE__, #expr); \ }) /* Record a test failure and exit if EXPR evaluates to false. */ @@ -60,7 +60,8 @@ __BEGIN_DECLS if (expr) \ ; \ else \ - support_test_verify_impl (1, __FILE__, __LINE__, #expr); \ + support_test_verify_exit_impl \ + (1, __FILE__, __LINE__, #expr); \ }) int support_print_failure_impl (const char *file, int line, @@ -70,8 +71,11 @@ void support_exit_failure_impl (int exit_status, const char *file, int line, const char *format, ...) __attribute__ ((noreturn, nonnull (2), format (printf, 4, 5))); -void support_test_verify_impl (int status, const char *file, int line, +void support_test_verify_impl (const char *file, int line, const char *expr); +void support_test_verify_exit_impl (int status, const char *file, int line, + const char *expr) + __attribute__ ((noreturn)); /* Record a test failure. This function returns and does not terminate the process. The failure counter is stored in a shared diff --git a/support/support_test_verify_impl.c b/support/support_test_verify_impl.c index 5bae38f..55ab211 100644 --- a/support/support_test_verify_impl.c +++ b/support/support_test_verify_impl.c @@ -22,12 +22,16 @@ #include void -support_test_verify_impl (int status, const char *file, int line, - const char *expr) +support_test_verify_impl (const char *file, int line, const char *expr) { support_record_failure (); printf ("error: %s:%d: not true: %s\n", file, line, expr); - if (status >= 0) - exit (status); +} +void +support_test_verify_exit_impl (int status, const char *file, int line, + const char *expr) +{ + support_test_verify_impl (file, line, expr); + exit (status); }