This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: False positive or bug in fortran/decl.c ?
- From: Fritz Reese <fritzoreese at gmail dot com>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Fri, 26 Aug 2016 06:49:28 -0400
- Subject: Re: False positive or bug in fortran/decl.c ?
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LSU.2.20.1608241406360.14886@anthias.pfeifer.com>
On Wed, Aug 24, 2016 at 8:10 AM, Gerald Pfeifer <gerald@pfeifer.com> wrote:
(snip)
> gcc-6.1.0/gcc/fortran/decl.c has code has code of the structure:
>
> static bool
> add_hidden_procptr_result (gfc_symbol *sym)
> {
(snip)
>
> if (case1 || case2)
> {
> gfc_symtree *stree;
> if (case1)
> gfc_get_sym_tree ("ppr@", gfc_current_ns, &stree, false);
> else if (case2)
> {
(snip)
> The compiler used to compile lang/gcc6 complained about stree not being
> initialized (when both parts of the if. . .else if. . . were not executed.
>
> The code would be less likely to produce the false positive if the "if
> (case2)" was not code: just use an else instead, possibly with a case2
> comment.
(snip)
I will leave whether this is worth committing up to a more experienced
maintainer. For the history books the proposed change is attached,
though there is no regression caused by the original code.
---
Fritz Reese
2016-08-26 Fritz Reese <fritzoreese@gmail.com>
gcc/fortran/
* decl.c (add_hidden_procptr_result): Simplify conditional.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index ce7254f..629b36d 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5327,7 +5327,7 @@ add_hidden_procptr_result (gfc_symbol *sym)
gfc_symtree *stree;
if (case1)
gfc_get_sym_tree ("ppr@", gfc_current_ns, &stree, false);
- else if (case2)
+ else
{
gfc_symtree *st2;
gfc_get_sym_tree ("ppr@", gfc_current_ns->parent, &stree, false);