- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
with the following code I get somewhat unexpected warnings for
"Overlapping storage initializations", which I do not understand:
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?
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?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like a bug to me. The first warning is highlighting the wrong source line, too. I will let the developers know - thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed for a future release.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page