Hi Zan and others,
I don't believe this is a IA64 problem. Have you checked on i386 or
> x86_64?
Yes, as pointed in my initial post, the exact same code runs as expected on
a standard x86 PC, not running Debian unfortunately, but with gcc 4.3 too.
So I can't make a direct comparison since the Linux distribution is
different, and probably the patches applied to the compiler chain, but at
least the gcc version is (roughly) the same.
> My first guess is that your program is calling atof without a function
> prototype, somehow. Be sure to compile with "-Wall -Wextra". Functions
> without a prototype default to an "int" return value.
I already had -Wall. No warning or error at all. Adding -Wextra didn't
display more.
> If you include <cstdlib> in your C++ source, make sure that you call it
> as std::atof or have an active "using namespace std;" somewhere in
> scope.
I have "using namespace std;" in a top-level header I'm including. So no
need for an explicit std::atof. BTW, shouldn't the compiler display a
warning or error if the atof definition isn't found?
> Another thing...I am pretty sure that std::string does not automatically
> convert to char*, so your atof( s ) example should be horribly wrong.
> atof( s.c_str() ) is the right way to do it. Unless someone added
> std::string to the prototypes in cstdlib when I wasn't looking.
No, you're right. I simply made a mistake when I copied the lines from my
test code. The second line should read indeed cout << atof( s.c_str() ) <<
endl; as you rightly pointed out.
I'm pretty sure my problem is due to header inclusion ordering. Two reasons
for that.
(1) When upgrating my system to gcc 4.3 (or 4.2, or perhaps even 4.1, I
don't remember exactly) I had to fix several undefined numeric_limits and
strcpy (and maybe several other symbols I don't remember now) due to
apparently some changes in the standard C/C++ headers. I mean, I had to
explicitly include <cstdlib> and <limits> to compile successfully where
before one of the other C/C++ headers (<iostream>, <cmath>?) seemed to
silently include them.
(2) An empty project with, for example, a simple call to cout << atof(
"0.113" ) << endl; rightly displays 0.113.
Thanks for your input anyway.
Émeric