It was to fix this issue.
Thanks Dave.
I haven't managed to prove that the inclusion of
-fwrapv achieves anything wrt perl, but there are some well credentialed perl developers saying that it does (or, at least, that it once did).
I'm not about to start arguing the point with them.
I guess, that if its inclusion does something useful then that's well and good. And if it doesn't do anything useful then it's harmless, anyway.
Interesting that the -SvIVX(sv) is still present in sv.c, because I think it's still undefined behaviour when SvIVX(sv) is IV_MIN (aka LONG_MIN), even if -fwrapv is somehow masking it when perl is involved.
UPDATE: The above sentence was incorrect. On reading the code properly (which involved minimal widening of my field of vision), I realize that
-SvIVX(sv) is never reached if
SvIVX(sv) is IV_MIN.
I haven't yet found any evidence that, in C, that switch ever alters anything.
$ cat LONG_MIN.c
#include <stdio.h>
#include <limits.h>
int main(void) {
printf("%ld %ld\n", LONG_MIN, -LONG_MIN);
return 0;
}
$ gcc -o LONG_MIN LONG_MIN.c
LONG_MIN.c: In function ‘main’:
LONG_MIN.c:6:33: warning: integer overflow in expression ‘-92233720368
+54775808’ of type ‘long int’ results in ‘-9223372036854775808’ [-Wove
+rflow]
6 | printf("%ld %ld\n", LONG_MIN, -LONG_MIN);
| ^
$ ./LONG_MIN
-9223372036854775808 -9223372036854775808
The compilation warning relates only to "-LONG_MIN".
It's exactly the same (in every respect) when I compile using the
-fwrapv switch, and
-ftrapv catches nothing.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.