Bug 64370 - [5 Regression] sreal.c:125:23: error: 'exp2' was not declared in this scope
Summary: [5 Regression] sreal.c:125:23: error: 'exp2' was not declared in this scope
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-21 15:23 UTC by John David Anglin
Modified: 2015-01-13 07:22 UTC (History)
3 users (show)

See Also:
Host: hppa1.1-hp-hpux10.20
Target: hppa1.1-hp-hpux10.20
Build: hppa1.1-hp-hpux10.20
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2014-12-21 15:23:39 UTC
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I/opt/gnu/gcc/gmp/include  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o sreal.o -MT sreal.o -MMD -MP -MF ./.deps/sreal.TPo ../../gcc/gcc/sreal.c
../../gcc/gcc/sreal.c: In member function 'double sreal::to_double() const':
../../gcc/gcc/sreal.c:125:23: error: 'exp2' was not declared in this scope
make[3]: *** [sreal.o] Error 1

Maybe fallback to pow?
Comment 1 Uroš Bizjak 2015-01-09 12:35:04 UTC
The exp2 call was substituted wiht scalbln as part of PR64503 fix.

Is this still an issue?
Comment 2 dave.anglin 2015-01-09 13:40:19 UTC
On 2015-01-09, at 7:35 AM, ubizjak at gmail dot com wrote:

> The exp2 call was substituted wiht scalbln as part of PR64503 fix.
> 
> 
> 
> Is this still an issue?

I will check but it would appear that it's still and issue.  scalbln is not available.  What
is available is ldexp and the size of int is the same as size of long.

Dave
--
John David Anglin	dave.anglin@bell.net
Comment 3 Mikhail Maltsev 2015-01-09 19:25:26 UTC
In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like this:

double
scalbn (double x, int y)
{
#if (FLT_RADIX == 2) && defined(HAVE_LDEXP)
  return ldexp (x, y); 
#else
  return x * pow (FLT_RADIX, y); 
#endif
}

Maybe something similar could be used here. If pow is not OK, something like this could be used:
return (y >= 0) ? x * (1 << y) : x / (1 << (-y)); (assuming that shift will not cause overflow).

BTW, what if FLT_RADIX != 2?
Comment 4 Uroš Bizjak 2015-01-09 19:31:16 UTC
(In reply to Mikhail Maltsev from comment #3)
> In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like this:
> 
> double
> scalbn (double x, int y)

You should be extra careful here, we are using scalbln to avoid overflows.  Please see PR64503, there are some ipa tests in the testsuite (e.g. gcc.dg/ipa/iinline-4.c) that report -inf for estimated badness when other functions are used.
Comment 5 dave.anglin 2015-01-09 20:40:12 UTC
On 2015-01-09 2:31 PM, ubizjak at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64370
>
>
>
> --- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
>
> (In reply to Mikhail Maltsev from comment #3)
>
>> In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like thi
> s:
>
>> double
>> scalbn (double x, int y)
>
>
> You should be extra careful here, we are using scalbln to avoid overflows.
>   
>
> Please see PR64503, there are some ipa tests in the testsuite (e.g.
>
> gcc.dg/ipa/iinline-4.c) that report -inf for estimated badness when other
>
> functions are used.

The change to using scalbln breaks hppa*-hpux11* as well:
g++ -c   -g -DIN_GCC    -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -
W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
-Wmissing-format-
attribute -Woverloaded-virtual -pedantic -Wno-long-long 
-Wno-variadic-macros -Wn
o-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -I. 
-I../../gcc/gcc -I../.
./gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
-I/opt/
gnu/gcc/gmp/include  -I../../gcc/gcc/../libdecnumber 
-I../../gcc/gcc/../libdecnu
mber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o sreal.o 
-MT srea
l.o -MMD -MP -MF ./.deps/sreal.TPo ../../gcc/gcc/sreal.c
../../gcc/gcc/sreal.c: In member function 'double sreal::to_double() const':
../../gcc/gcc/sreal.c:125:30: error: 'scalbln' was not declared in this 
scope
      val = scalbln (val, m_exp);


I am puzzled why scalbln was used as m_exp has type "signed int". The 
code also seems
to be specific to a radix of 2.  So, ldexp (x, y) or x * pow (2, y) seem 
like the correct functions
to use.  Also note that an int type should hold the full range of 
exponents for double
on every machine that I'm aware of, so it doesn't seem like there is any 
benefit in using
scalbln over ldexp.

I have read that there are problems with overflow detection on alpha.  
So, is that the issue?

Dave
Comment 6 Jakub Jelinek 2015-01-12 11:09:03 UTC
Do you have ldexp on HPUX?  Asking because that is used in jcf-dump already...
Comment 7 Uroš Bizjak 2015-01-12 11:16:20 UTC
(In reply to dave.anglin from comment #5)
> 
> I have read that there are problems with overflow detection on alpha.  
> So, is that the issue?

The issue us that -inf will ICE with FP exception on alpha. I don't think -inf (which is otherwise produced on other targets) is valid result, and using scalbln avoids it.
Comment 8 dave.anglin 2015-01-12 13:24:59 UTC
On 2015-01-12, at 6:09 AM, jakub at gcc dot gnu.org wrote:

> Do you have ldexp on HPUX?  Asking because that is used in jcf-dump already...

Yes, it's available on hpux10.20 and hpux11.

Dave
--
John David Anglin	dave.anglin@bell.net
Comment 9 Jakub Jelinek 2015-01-12 20:30:41 UTC
Author: jakub
Date: Mon Jan 12 20:30:09 2015
New Revision: 219489

URL: https://gcc.gnu.org/viewcvs?rev=219489&root=gcc&view=rev
Log:
	PR other/64370
	* sreal.c (sreal::to_double): Use ldexp instead of scalbnl.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sreal.c
Comment 10 Jakub Jelinek 2015-01-12 20:43:14 UTC
Assuming fixed then.
Comment 11 Uroš Bizjak 2015-01-13 07:22:57 UTC
(In reply to Jakub Jelinek from comment #10)
> Assuming fixed then.

ldexp is also OK for alpha.