- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a post on Fortran discourse (https://fortran-lang.discourse.group/t/example-from-reinhold-baders-tutorial-curious-result/9298/9) I present a program that is accepted by ifx but not by gfortran. It seems that the ifx compiler (at least the version I used) is ignoring the error in it.
Here is the program:
! fillnull.f90 --
! Use a constructor with null() to see what happens to ordinary scalars
!
! This is not accepted by gfortran, but it is by ifx 2025.0.0
!
program fillnull
implicit none
type :: simple
integer :: value(1) = [10]
end type simple
type(simple) :: a
write(*,*) 'Default: ', a
a = simple(null())
write(*,*) 'After null(): ', a
end program fillnull
If you change the value component to a scalar, it is also accepted without a warning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting it to us. I have escalated it to the development team and the fix will come with upcoming compiler updates.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's what NAG Fortran says:
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7222
Error: t.f90, line 12: In constructor for type SIMPLE, value for non-allocatable non-pointer component VALUE is intrinsic function NULL reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting it to us. I have escalated it to the development team and the fix will come with upcoming compiler updates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for picking this up. I have no idea how common this feature is used, but getting a proper warning/error message is important enough, perhaps especially for rarely used features.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The ifx compiler version 2025.1 emits an error #9211 for this code:
$ ifx test.f90
test.f90(12): error #9211: In a structure constructor, the intrinsic function NULL must only be used for a POINTER or ALLOCATABLE component. [VALUE]
a = simple(null())
---------------^
compilation aborted for test.f90 (code 1)
So, the problem is corrected in the latest compiler release.

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