]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Avoid freeing uninitialized value
authorMartin Jambor <mjambor@suse.cz>
Thu, 26 Jun 2025 09:25:20 +0000 (11:25 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 26 Jun 2025 09:25:48 +0000 (11:25 +0200)
When compiling fortran/match.cc, clang emits a warning

  fortran/match.cc:5301:7: warning: variable 'p' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]

which looks accurate, so this patch adds an initialization of p to
avoid the use.

gcc/fortran/ChangeLog:

2025-06-23  Martin Jambor  <mjambor@suse.cz>

* match.cc (gfc_match_nullify): Initialize p to NULL;

gcc/fortran/match.cc

index aa0b04afd563cb22b58112b5e9e418a60651e208..8355a390ee08c632e7063ea4341dca45ab3b4707 100644 (file)
@@ -5293,7 +5293,7 @@ match
 gfc_match_nullify (void)
 {
   gfc_code *tail;
-  gfc_expr *e, *p;
+  gfc_expr *e, *p = NULL;
   match m;
 
   tail = NULL;