This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/29459] Spurious warning about uninitialized optional arguments
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Aug 2007 14:10:15 -0000
- Subject: [Bug fortran/29459] Spurious warning about uninitialized optional arguments
- References: <bug-29459-9647@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from fxcoudert at gcc dot gnu dot org 2007-08-14 14:10 -------
Reduced testcase:
subroutine print_sub(l, labels)
logical :: l
character (len=*), optional :: labels(1)
if (l) call foo
if (present(labels)) then
print *, labels(1)
end if
end
The logical and corresponding if clause are only here to prevent the optimizer
being too clever, but any non-trivially-dead code works as well. The tree dump
for this is along the lines of:
print_sub (l, labels, _labels)
{
char[1][1:_labels] * labels.0;
if (labels != 0B)
labels.0 = (char[1][1:_labels] *) labels;
if (*l)
foo()
if (labels != 0B)
{
_gfortran_transfer_character (&dt_parm.0, &(*labels.0)[0][1]{lb: 1 sz:
1}, _labels);
_gfortran_st_write_done (&dt_parm.0);
}
}
I suspect that '<anonymous>' is labels.0 (though it *has* a name!), because
it's set in the first if-block and used in the second. If the optimizer is
intelligent enough to remove the code in-between, the warning disappears.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-01-31 23:15:40 |2007-08-14 14:10:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29459