[Bug c/24971] New: missing prototype causes strange effect at a distance with float.
(972) uname -a FreeBSD gadoid.ices.cmu.edu 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Mon Feb 23 20:45:55 GMT 2004 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC i386 (973) cat a.c #include #include int main(int argc,char *argv[]) { float n = 40; int i; for (i = 0;i < 10;i++) foo(); printf("%g\n",n + 2.0); return 0; } float foo() { return 1.0; } (974) gcc a.c -o a a.c:17: warning: type mismatch with previous implicit declaration a.c:10: warning: previous implicit declaration of `foo' a.c:17: warning: `foo' was previously implicitly declared to return `int' (975) ./a nan (976) The above program is missing a prototype for the "foo" function. This correctly causes a warning, but the missing prototype causes problems for completely unrelated code. In the above example, the foo() function is called 10 times, then an unrelated floating point operation is peformed which incorrectly results in a "nan". Note that if the number of loop iterations is reduced to 6 or fewer times, the program will print the correct result. -- Summary: missing prototype causes strange effect at a distance with float. Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hansen at cmu dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971
[Bug c/24972] New: missing prototype causes strange effect at a distance with float.
(972) uname -a FreeBSD gadoid.ices.cmu.edu 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Mon Feb 23 20:45:55 GMT 2004 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC i386 (973) cat a.c #include #include int main(int argc,char *argv[]) { float n = 40; int i; for (i = 0;i < 10;i++) foo(); printf("%g\n",n + 2.0); return 0; } float foo() { return 1.0; } (974) gcc a.c -o a a.c:17: warning: type mismatch with previous implicit declaration a.c:10: warning: previous implicit declaration of `foo' a.c:17: warning: `foo' was previously implicitly declared to return `int' (975) ./a nan (976) The above program is missing a prototype for the "foo" function. This correctly causes a warning, but the missing prototype causes problems for completely unrelated code. In the above example, the foo() function is called 10 times, then an unrelated floating point operation is peformed which incorrectly results in a "nan". Note that if the number of loop iterations is reduced to 6 or fewer times, the program will print the correct result. -- Summary: missing prototype causes strange effect at a distance with float. Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hansen at cmu dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24972
[Bug c/24973] New: missing prototype causes strange effect at a distance with float.
(972) uname -a FreeBSD gadoid.ices.cmu.edu 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Mon Feb 23 20:45:55 GMT 2004 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC i386 (973) cat a.c #include #include int main(int argc,char *argv[]) { float n = 40; int i; for (i = 0;i < 10;i++) foo(); printf("%g\n",n + 2.0); return 0; } float foo() { return 1.0; } (974) gcc a.c -o a a.c:17: warning: type mismatch with previous implicit declaration a.c:10: warning: previous implicit declaration of `foo' a.c:17: warning: `foo' was previously implicitly declared to return `int' (975) ./a nan (976) The above program is missing a prototype for the "foo" function. This correctly causes a warning, but the missing prototype causes problems for completely unrelated code. In the above example, the foo() function is called 10 times, then an unrelated floating point operation is peformed which incorrectly results in a "nan". Note that if the number of loop iterations is reduced to 6 or fewer times, the program will print the correct result. -- Summary: missing prototype causes strange effect at a distance with float. Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hansen at cmu dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24973
[Bug c/24971] missing prototype causes strange effect at a distance with float.
--- Comment #5 from hansen at cmu dot edu 2005-11-21 15:28 --- (In reply to comment #2) > Note the error is: > t.c:17: error: conflicting types for foo > t.c:10: error: previous implicit declaration of foo was here > I only get warnings in 3.3.0. Even with warnings, I still do not think that there should be an effect in code unrelated to the warning. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971