[Bug fortran/31683] bogus warnings with optional arguments

tkoenig at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Apr 24 20:06:00 GMT 2007



------- Comment #4 from tkoenig at gcc dot gnu dot org  2007-04-24 21:06 -------
There is a questionable practice with the original code:  It uses
pab without a check whether it is present.

The compiler tries to guard against this, partially by generating
(from the *.original dump):

  if (pab != 0B)
    {
      {
        int4 D.1054;

        D.1054 = pab->dim[0].stride;
        stride.1 = D.1054 == 0 ? 1 : D.1054;
        pab.0 = (real8[0:D.1055] *) pab->data;
        ubound.0 = (pab->dim[0].ubound - pab->dim[0].lbound) + 1;
        stride.3 = pab->dim[1].stride;
        ubound.2 = (pab->dim[1].ubound - pab->dim[1].lbound) + 1;
        size.5 = stride.3 * NON_LVALUE_EXPR <ubound.2>;
        offset.4 = -stride.1 - NON_LVALUE_EXPR <stride.3>;
        D.1055 = size.5 - 1;
        D.1056 = (bit_size_type) (<unnamed-unsigned:32>) size.5 * 64;
        D.1057 = (<unnamed-unsigned:32>) size.5 * 8;
      }
    }

All these variables are initialized in this block, and nowhere
else.  Later in the loop, they are used, which generates the warnings.

The if(pab) above doesn't really help because the code will crash, or produce
strange results, if pab isn't present.

This is a very misleading diagnostic, but not a wrong-code as far as I can see.


-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-24 21:06:01
               date|                            |
            Summary|bogus warnings /            |bogus warnings with optional
                   |miscompilation              |arguments


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31683



More information about the Gcc-bugs mailing list