This is the mail archive of the 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: [Bug 8861] Revised patch - floating point literal mangling

> What about issues related to accuracy of translation (rounding style, 
> excess precision etc).  There are many floating point numbers where it is 
> hard if not impossible to guarantee that two independent implementations 
> will produce the same result.  That effectively means that the ABI is 
> mandating something which is ambiguously specified.

You're correct.  And, realistically, there will probably be differences
between implementations.  The LIA stuff is supposed to make this more
accurate, but the basic reason that C++ doesn't allow floating-point
template parameters are exactly the reasons you cite above.  The fact
that floating-point expression can sneak in through the kind of examples
that Zack gave is unfortunate, from that perspective.
> I'm surprised, given that 
> 	template <int I> void f(A<I+int(1.234+1.234)> a) { ... }
> and
> 	template <int I> void f(A<I+int(2.468)> a) { ... }
> don't mangle identically, that a representation of the literal *as it 
> appeared in the source* isn't used.

That would be the best choice -- but most compilers don't have that
information available at the point where its needed.  We certainly don't
have that information available in GCC.

Mark Mitchell
CodeSourcery, LLC

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