False positive or bug in fortran/decl.c ?

Fritz Reese fritzoreese@gmail.com
Fri Aug 26 10:49:00 GMT 2016


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: decl_cases.patch
Type: text/x-patch
Size: 435 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20160826/1b5167b8/attachment.bin>


More information about the Fortran mailing list