Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 1996 15:36:26 +0100 (MET)
From:      Philippe Regnauld <regnauld@tetard.frmug.fr.net>
To:        current@freebsd.org (current)
Subject:   Weird atof() behavior
Message-ID:  <199603301436.PAA13952@tetard.frmug.fr.net>

next in thread | raw e-mail | index | archive | help
Hi,

	A  friend of mine  has had  some problems with  Rayshade running on
	2.0.5 (GCC   2.6.3)   -- it appeared   that  atof()  systematically
	returned bogus values in certain conditions: if you omit to specify
	#include <stdlib.h>,  gcc  does NOT issue  any sort  of warning for
	atof().  Example:

	#include <stdio.h>

	main()
	{
		foo* char="3.1415926";
		float bar=atof(foo);
		printf("%f\n",bar);
	}

	Here's the output:

	-7.000000

	This is obviously a GCC related  problem (I've got the same results
	with current), as testing with 2.5.8 showed  no problems.  It seems
	that the value from is cast to a double, then cast to an int.  

	The warning does show up with -Wall:
	
	atof.c:5: warning: implicit declaration of function `atof'

								-- Phil





-- 
- [ regnauld@tetard.frmug.fr.net / +48.8N+2.3E / +33 1 4507 9391 / Sol 3 ] -
- [ regnauld@freenix.fr		 / FreeBSD 2.x /  			 ] -
  "Le schtroumpf est à l'homme ce que le bleu est au billard" - F.Berjon




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603301436.PAA13952>