public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24971]  New: missing prototype causes strange effect at a distance with float.
@ 2005-11-21 15:12 hansen at cmu dot edu
  2005-11-21 15:16 ` [Bug c/24971] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hansen at cmu dot edu @ 2005-11-21 15:12 UTC (permalink / raw)
  To: gcc-bugs

(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     root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC 
i386
(973) cat a.c
#include <stdlib.h>
#include <stdio.h>

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/24971] missing prototype causes strange effect at a distance with float.
  2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
@ 2005-11-21 15:16 ` pinskia at gcc dot gnu dot org
  2005-11-21 15:16 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 15:16 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-11-21 15:16 -------
Note the error is:
t.c:17: error: conflicting types for ‘foo’
t.c:10: error: previous implicit declaration of ‘foo’ was here


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/24971] missing prototype causes strange effect at a distance with float.
  2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
  2005-11-21 15:16 ` [Bug c/24971] " pinskia at gcc dot gnu dot org
@ 2005-11-21 15:16 ` pinskia at gcc dot gnu dot org
  2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 15:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-21 15:16 -------
This code should have been rejected as it is for 3.4.0 and above.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |accepts-invalid
         Resolution|                            |FIXED
   Target Milestone|---                         |3.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/24971] missing prototype causes strange effect at a distance with float.
  2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
  2005-11-21 15:16 ` [Bug c/24971] " pinskia at gcc dot gnu dot org
  2005-11-21 15:16 ` pinskia at gcc dot gnu dot org
@ 2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
  2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
  2005-11-21 15:28 ` hansen at cmu dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-11-21 15:18 -------
*** Bug 24972 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/24971] missing prototype causes strange effect at a distance with float.
  2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
                   ` (2 preceding siblings ...)
  2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
@ 2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
  2005-11-21 15:28 ` hansen at cmu dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2005-11-21 15:18 -------
*** Bug 24973 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24971


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/24971] missing prototype causes strange effect at a distance with float.
  2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
                   ` (3 preceding siblings ...)
  2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
@ 2005-11-21 15:28 ` hansen at cmu dot edu
  4 siblings, 0 replies; 6+ messages in thread
From: hansen at cmu dot edu @ 2005-11-21 15:28 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]



------- 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-21 15:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-21 15:12 [Bug c/24971] New: missing prototype causes strange effect at a distance with float hansen at cmu dot edu
2005-11-21 15:16 ` [Bug c/24971] " pinskia at gcc dot gnu dot org
2005-11-21 15:16 ` pinskia at gcc dot gnu dot org
2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
2005-11-21 15:19 ` pinskia at gcc dot gnu dot org
2005-11-21 15:28 ` hansen at cmu dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).