Bug 31279

Summary: Uninitialized warning for call-by-reference arguments with known intent(in)
Product: gcc Reporter: Tobias Burnus <burnus>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: enhancement CC: gcc-bugs, P.Schaffnit
Priority: P3 Keywords: diagnostic
Version: 4.3.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34721
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2012-02-02 00:00:00
Bug Depends on: 31094    
Bug Blocks: 24639    

Description Tobias Burnus 2007-03-20 15:41:56 UTC
In Fortran one can specify the intent of variables thus if all arguments have INTENT(IN) then GCC should be able to detect that alist in the call to cshift is uninitialized.

This depends on the middle end support of intents (PR31094) plus using these in gfortran.

Example (using an intrinsic function):

program testcshft
  integer :: alist(4)
  alist =cshift(alist,-1)
  write(*,*) alist
end program testcshft
Comment 1 Andrew Pinski 2012-02-02 17:49:32 UTC
Confirmed.
Comment 2 Dominique d'Humieres 2013-06-25 09:10:09 UTC
Still no warning at revision 200371.
Comment 3 Richard Biener 2017-03-02 10:09:49 UTC
Several(?) C duplicates exist which implicitely suggest a similar attribute.

void bar (int *);
void foo ()
{
  int i;
  bar (&i);
}

if we can annotate the first arg of 'bar' as "intent in" (aka, should be
fully(!) initialized) then we can warn on this use.