public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran: Silence -Wmaybe-uninitialized warning
@ 2021-10-31 16:25 Bernhard Reutner-Fischer
  2021-10-31 17:05 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2021-10-31 16:25 UTC (permalink / raw)
  To: gcc-patches, fortran; +Cc: Bernhard Reutner-Fischer, Bernhard Reutner-Fischer

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/fortran/ChangeLog:

	* resolve.c (resolve_fl_procedure): Initialize
	allocatable_or_pointer.

---
fortran/resolve.c: In function 'bool resolve_fl_procedure(gfc_symbol*, int)':
fortran/resolve.c:13391:7: warning: 'allocatable_or_pointer' may be used uninitialized in this function [-Wmaybe-uninitialized]
13390 |   if (sym->attr.elemental && sym->result
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13391 |       && allocatable_or_pointer)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~
.../fortran/resolve.c:13197:8: note: 'allocatable_or_pointer' was declared here
13197 |   bool allocatable_or_pointer;
      |        ^~~~~~~~~~~~~~~~~~~~~~

Bootstrapped and regtested without regressions.
Ok for trunk?
---
 gcc/fortran/resolve.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 8da396b32ec..21126cba262 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -13179,7 +13179,7 @@ static bool
 resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
 {
   gfc_formal_arglist *arg;
-  bool allocatable_or_pointer;
+  bool allocatable_or_pointer = false;
 
   if (sym->attr.function
       && !resolve_fl_var_and_proc (sym, mp_flag))
-- 
2.33.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fortran: Silence -Wmaybe-uninitialized warning
  2021-10-31 16:25 [PATCH] Fortran: Silence -Wmaybe-uninitialized warning Bernhard Reutner-Fischer
@ 2021-10-31 17:05 ` Thomas Koenig
  2021-10-31 17:31   ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2021-10-31 17:05 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer, gcc-patches, fortran; +Cc: Bernhard Reutner-Fischer

Hi Bernhard,

> gcc/fortran/ChangeLog:
> 
> 	* resolve.c (resolve_fl_procedure): Initialize
> 	allocatable_or_pointer.



Looking at the code, it is clear that this is a false
positive, or a false maybe, but the semantics of C/C++
may well indicate that sym->result could change, although
it clearly does not.

So, OK.

Thanks for the patch!

Best regards

	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fortran: Silence -Wmaybe-uninitialized warning
  2021-10-31 17:05 ` Thomas Koenig
@ 2021-10-31 17:31   ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2021-10-31 17:31 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: rep.dot.nop, gcc-patches, fortran, Bernhard Reutner-Fischer

On Sun, 31 Oct 2021 18:05:36 +0100
Thomas Koenig <tkoenig@netcologne.de> wrote:

> Hi Bernhard,
> 
> > gcc/fortran/ChangeLog:
> > 
> > 	* resolve.c (resolve_fl_procedure): Initialize
> > 	allocatable_or_pointer.  
> 
> Looking at the code, it is clear that this is a false
> positive, or a false maybe, but the semantics of C/C++
> may well indicate that sym->result could change, although
> it clearly does not.

Agree wholeheartedly
> 
> So, OK.

pushed as r12-4811
> 
> Thanks for the patch!

I have to thank you for the quick review!
cheers,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-31 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 16:25 [PATCH] Fortran: Silence -Wmaybe-uninitialized warning Bernhard Reutner-Fischer
2021-10-31 17:05 ` Thomas Koenig
2021-10-31 17:31   ` Bernhard Reutner-Fischer

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).