[Info-vax] C compiler question
Craig A. Berry
craigberry at nospam.mac.com
Sat Jul 27 18:10:44 EDT 2019
On 7/27/19 11:57 AM, Mark Berryman wrote:
> Something I see all the time when porting unix code is something similar
> to the following:
>
> unsigned int x;
> .
> .
> .
> if (x <= 0) {something}
>
> This, of course, generates a QUESTCOMPARE informational.
FWIW, most other compilers also warn about this now. There is a line of
code in the Perl sources guarded with 4 lines of warning suppression
code for clang and gcc because the author of the line in question
insists that it is perfectly idiomatic and well-defined C to check
whether an unsigned value is less than zero:
CLANG_DIAG_IGNORE_STMT(-Wtautological-compare);
GCC_DIAG_IGNORE_STMT(-Wtype-limits);
neg = PL_statcache.st_ino < 0;
GCC_DIAG_RESTORE_STMT;
CLANG_DIAG_RESTORE_STMT;
I cannot stomach the thought of turning that mess into the following for
VMS so I just ignore the message:
#ifdef __DECC || DECCXX
# pragma message disable (QUESTCOMPARE)
#endif
CLANG_DIAG_IGNORE_STMT(-Wtautological-compare);
GCC_DIAG_IGNORE_STMT(-Wtype-limits);
neg = PL_statcache.st_ino < 0;
GCC_DIAG_RESTORE_STMT;
CLANG_DIAG_RESTORE_STMT;
#ifdef __DECC || DECCXX
# pragma message enable (QUESTCOMPARE)
#endif
More information about the Info-vax
mailing list