Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Обсуждение

Evaluation of logical expressions with mixed arguments

OP1
Новый участник III
385Просмотр.
Hi,

Is it possible to have the compiler warn about the following situation:

...
LOGICAL :: FLAG
...
IF (FLAG == 'yes') THEN
...

In other words: the logical expression is made of a logical and a variable from another type. The compiler probably converts 'yes' into a logical (I suppose this is the same situation as having expressionswhere reals are mixed with integers or other kinds of variables, for instance).

So, is there a way to force the compiler to emit a warning in these situations? Or to prevent the compiler from converting argumentsof an expression based on the nature of the first argument?

Thanks,

Olivier
0 баллов
2 Ответы
Steven_L_Intel1
Сотрудник
385Просмотр.
Turning on standards checking will warn you about this. There are two things non-standard here. The first is the use of a character literal which is treated as a Hollerith constant in non-character contexts. Then there's the non-standard comparison of a logical to a numeric datatype.

There is not an option to disallow logical-numeric conversions, or one to warn speciifically about those. Both are things already on our "wish list".
OP1
Новый участник III
385Просмотр.

Ah, excellent, that did the trick. I am glad these are on your wish list - these programming errors can easily fly under the radar.

Thanks Steve!

Olivier

Ответить