This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR libstdc++/13045 / C++ demangler, floating values and function pointer type return type postfix fix.


On Mon, Nov 24, 2003 at 08:44:17AM -0500, Jerry Quinn wrote:
> I have a couple of curiosity questions:
> 
> 1) Are IEEE numbers the only ones that will ever be seen by
>    print_IEEE_fp?

It seems that the ABI defines that the hex float value
is a direct representation of the bits in a float/double
of the target machine :(.  So, no.  In that case it will
output nonsense.  But, from the point of view of a cross
compiler, there is not reasonable way for a demangler
to know what the target WAS - so I chose to handle everything
as IEEE and sorry for the those who own a Cray.

> 2) Why not use sprintf?

The only reasonable reason I had for that is that
this demangler promises never to call malloc() or new.
It only allocates memory through the Allocator template
parameter.  sprintf(buf, "%e", ...) MIGHT call malloc(),
certainly on machines that do not glibc.

> 3) Why not use code based on floatconv.c in libio?

Same reason.

> I'm in the midst of getting a floating point printing patch based on
> the floatconv code ready for the v3 library, so I'm wondering whether
> the printer you wrote would make better sense as a base than the
> floatconv-based code I have.

My code is written in C++,
it does not allocate any memory,
it might be faster or slower (you will have to test that),
it has no support whatsoever for formatting, other then
limit the number of digits that are printed: the goal of
this print routine is to provide so many digits that it
is garanteed that assigning that decimal value to a double
it will produce the exact same binary image, and thus symbol.
For example, if you write code with 1.2345599999999999, it
will output 1.2345599999999999; but if you write code
with 1.23456, it will output 1.2345600000000001 (which is
the best representation of ACTUAL binary image of the resulting
double).  A normal printing routine might be better off
by rounding off one more digit (well, my code can do THAT,
but not any other formatting).  So, if you need formatting,
then you still can use the binary to decimal convert part
but you will have to rewrite the actual print part I think.

> Jerry Quinn

-- 
Carlo Wood <carlo@alinoe.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]