This is the mail archive of the gcc-bugs@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: Problem with non-ISO C scalb() builtin


 > From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001@yahoo.co.nz>
 > 
 > >  > Danny Smith wrote:
 > 
 > >  > > double  scalb (double, double);
 > >  > > as in __builtin_scalb
 > >  > 
 > >  > That is a gcc bug.  The second argument to scalb should be int to match 
 > >  > glibc (and presumably the BSD library).  This should only be a temporary 
 > >  > problem.
 > > 
 > > Er, I don't think it is a gcc bug.  The glibc headers on my RH box as
 > > well as math.h on solaris2.7 & irix6.5 and the xopen standard all
 > > describe scalb as taking two doubles.  It is scalbn (with an "n") that
 > > takes a double and an int.  See:
 > > http://www.opengroup.org/onlinepubs/007904975/functions/scalb.html
 > > vs:
 > > http://www.opengroup.org/onlinepubs/007904975/functions/scalbn.html
 > > 
 > > I believe in this case your C library is inconsistent with the
 > > standard.
 > 
 > No.  It is consistent with ANSI std, not XOPEN.  If
 > you look in newlib, there is allowance for both versions of scalb

But scalb _isn't_ part of ANSI, it's an extension of some sort.  (Note
in your first posting how you show scalb is wrapped in #ifndef
__STRICT_ANSI__.)  And it's an extension that your system does
differently than most others (newlib notwithstanding.)

Anyway, let's figure out a solution.  I can think of several:

1.  Kill the scalb builtin.
2.  Change builtin scalb to the mingw32 style, but disable it on
    probably all "unix"-like systems.
3.  Leave builtin scalb alone, disable it on mingw32 (and anywhere else 
    we see a complaint.  Are there any other problematic systems?)

IMHO, we probably want to do #3.  I believe that would entail setting
up a target init_builtins for mingw32 which just calls:

   disable_builtin_function ("scalb")

Do you agree with this approach, and do you feel comfortable coding
it, or would you like some help?


 > >  > Is the best thing to do in this case simply to make
 > >  > -fno-builtin-scalb the default for mingw32 target?
 > > 
 > > IMHO, probably yes.  (Do you need help with that?  Let me know.)  You
 > > might also want to submit a fix for scalb to your libc maintainers.
 > > 
 > Umm, libc in mingw32 case is MSVCRT.dll.  I don't think MS will change
 > anything just for the benefit of mingw32.

I don't follow mingw32 development, as you can probably tell. :-)


 > But I could just delete declaration
 > of scalb in mingw32's math.h, leaving the underscored _scalb declaration in place
 > (perhaps with _attribute__((__deprecated__)).

Are you proposing deleting scalb from just your own box's math.h, or
in the mingw32 source tree?  I prefer a solution that solves this for
everybody.  (Although this is a rare problem, i.e. a warning, which
appears only with -Wsystem-headers, on just mingw32.)


 > Should -std=c89 or -std=c99 imply -fno-nonansi-builtins
 > Danny
 
Yes, I believe it does.

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


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