public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/101912 - testcase for fixed uninit case
@ 2023-01-09 11:08 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-01-09 11:08 UTC (permalink / raw)
  To: gcc-patches

We now properly optimize this testcase and no longer diagnose
a bogus uninit use.

Tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/101912
	* gcc.dg/uninit-pr101912.c: New testcase.
---
 gcc/testsuite/gcc.dg/uninit-pr101912.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/uninit-pr101912.c

diff --git a/gcc/testsuite/gcc.dg/uninit-pr101912.c b/gcc/testsuite/gcc.dg/uninit-pr101912.c
new file mode 100644
index 00000000000..1550c03436d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr101912.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+int getint (void);
+int
+tzloadbody (void)
+{
+  int n = getint ();
+  int prevcorr;
+  int leapcnt = 0;
+  for (int i = 0; i < n; i++)
+    {
+      int corr = getint ();
+      if (corr < 1 || (corr == 1 && !(leapcnt == 0 || (prevcorr < corr ? corr == prevcorr + 1 : (corr == prevcorr || corr == prevcorr - 1))))) /* { dg-bogus "uninitialized" } */
+	return -1;
+
+      prevcorr = corr;
+      leapcnt++;
+    }
+  return leapcnt;
+}
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-09 11:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 11:08 [PATCH] tree-optimization/101912 - testcase for fixed uninit case Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).