Rev | Line | |
---|
[1] | 1 |
|
---|
| 2 | GCC Compiler Bug
|
---|
| 3 | ----------------
|
---|
| 4 |
|
---|
| 5 | Reference: http://boudicca.tux.org/hypermail/linux-kernel/2000week05/0983.html
|
---|
| 6 |
|
---|
| 7 | From: Johan Kullstam (kullstam@ne.mediaone.net)
|
---|
| 8 | Date: Thu Jan 27 2000 - 18:00:28 EST
|
---|
| 9 |
|
---|
| 10 | Horst von Brand <vonbrand@sleipnir.valparaiso.cl> writes:
|
---|
| 11 |
|
---|
| 12 | > My question in this vein would be the -fno-strength-reduce. The gcc bug
|
---|
| 13 | > that placed this in the kernel was in gcc-2.7.2, and was worked around in
|
---|
| 14 | > 2.7.2.3 by just making this option unconditional. Both 2.2.15pre4 and
|
---|
| 15 | > 2.3.41pre2 at least demand gcc-2.7.2.3 as minimal version.
|
---|
| 16 |
|
---|
| 17 | just when you thought it was safe to go into the water...
|
---|
| 18 |
|
---|
| 19 | strength-reduction is broken again in gcc-2.95.2 (aka the current
|
---|
| 20 | release). i'm not sure about what versions actually do work.
|
---|
| 21 |
|
---|
| 22 | for fun, try this one out. cut and paste the program bug.c.
|
---|
| 23 |
|
---|
| 24 | $ gcc -O2 bug.c -o b0
|
---|
| 25 | $ gcc -O2 -fno-strength-reduce bug.c -o b1
|
---|
| 26 |
|
---|
| 27 | run b1. notice it finish immediately.
|
---|
| 28 | now run b0. notice how b0 never terminates (until you ^C it).
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | -- bug.c -----------------------------------------
|
---|
| 32 | static void bug(int size, int tries)
|
---|
| 33 | {
|
---|
| 34 | int i;
|
---|
| 35 | int num = 0;
|
---|
| 36 |
|
---|
| 37 | while (num < size)
|
---|
| 38 | {
|
---|
| 39 | for (i = 1; i < tries; i++) num++;
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | int main()
|
---|
| 44 | {
|
---|
| 45 | bug(5, 10);
|
---|
| 46 | return 0;
|
---|
| 47 | }
|
---|
| 48 | -- bug.c -----------------------------------------
|
---|
| 49 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.