Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28434 Discussions

Fun with "Overlapping storage initializations encountered" warnings

Harald
Beginner
352 Views
Hello,

with the following code I get somewhat unexpected warnings for
"Overlapping storage initializations", which I do not understand:

[fortran]program ifort_init_warnings
  implicit none
  type t
     integer         :: i = 0
  end type t
  type(t), parameter :: t1 = t(1)   ! t1 is a scalar
  type(t), parameter :: a(1) = t(1) ! No warning (good!)
  type(t)            :: b(1) = t(1) ! Warning (needless)
  type(t)            :: c(1) = t1
  print *, a(1)% i
  print *, b(1)% i
  print *, c(1)% i
end program ifort_init_warnings
[/fortran]
% ifort -stand f03 -standard-semantics -warn all ifort_init_warnings.f90
ifort_init_warnings.f90(6): warning #5436: Overlapping storage initializations encountered with C
type(t), parameter :: t1 = t(1) ! t1 is a scalar
-------------------------------^
ifort_init_warnings.f90(8): warning #5436: Overlapping storage initializations encountered with B
type(t) :: b(1) = t(1) ! Warning (needless)
---------------------------------^

Remarks:

(1) The warnings do not appear if a,b,c are scalars instead of arrays.

(2) The first warning (for line #6) is really confusing, there's no C here.

(3) The warnings disappear if I remove the default initializer for the
component "i" of the derived type t. However, having a default
initialization is usually a good thing. I also do not get a warning
when using t(), but then b and c would have the wrong values ... :-/

Now I wonder why there is no warning for line #7 :-)

Is there a reason why I should get the warnings? Is it just too difficult
to detect a real overlapping initialization, so the compiler warns just in case?

0 Kudos
3 Replies
Steven_L_Intel1
Employee
352 Views
Looks like a bug to me. The first warning is highlighting the wrong source line, too. I will let the developers know - thanks.
0 Kudos
Steven_L_Intel1
Employee
351 Views
Thanks for the nice example. The warnings are inappropriate - it is legal to supply a component in a structure constructor for a component with default initialization. The location for the first warning is wrong, and the warnings are not identified as standards warnings (which they apparently should be in the cases where this warning is appropriate.) I have escalated this to the developers as issue DPD200176909.
0 Kudos
Steven_L_Intel1
Employee
351 Views
This has been fixed for a future release.
0 Kudos
Reply