Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26751 Discussions

warning assigning 64bit integer value to 32bit integer variable

andrew_4619
Honored Contributor I
226 Views

I recently changed a 32bit build to a 64bit build. In most instances everything works fine due to judicious use of properly defined integer kinds. I am still finding one or two more subtle bugs. Is there a compiler warning where an i8 result is assigned to an i4 variable? That would be useful for finding a certain class of potential bug. I had a hunt for an option but didn't find it.  I today found I had an SDK routine that now has an i8 return value and in some cases it was bashed into an i4 variable. This worked ok in many cases but in some cases caused logic bugs.   

0 Kudos
5 Replies
Steve_Lionel
Black Belt Retired Employee
219 Views

Unfortunately, there is no such warning available in Intel Fortran.

mecej4
Black Belt
209 Views

Andrew, please try the options -Wall, -Wconversion and -Wconversion-extra in GFortran.

andrew_4619
Honored Contributor I
193 Views

Thanks for the feedback Guys, knowing the option does not exits in ifort is very helpful as searching for Unicorns is not productive.  -Wconversion-extra in gfortran is proving most useful as whilst is has thrown up a whole list of stuff that is not relevant or important it has shown some items that do need attention.   Steve (font of all such knowledge), has  such an option been considered/rejected at intel in the past do you know?

Steve_Lionel
Black Belt Retired Employee
184 Views

DVF/CVF had run-time integer overflow checking, supported by DEC's code generator. The Intel code generator didn't support this and requests to add it were denied. It may be that the new LLVM-based code generator has that available already (I don't know) and if so, it could be added to the compiler.

A general warning on assignment of a larger type to a smaller one would go under a "usage" diagnostic option I requested during my time at Intel. I think it would be a promising idea, but I'm not aware that there is an active feature request for it. 

FortranFan
Honored Contributor II
212 Views

This is where using 2 or more compilers on one's codebase - if feasible - really helps.

I believe the static analyzer in GCC/gfortran will warn you of such instances as might others e.g., NAG?

Reply