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]

optimization/9325: wrong conversion of constants: (int)(float)(int) (INT_MAX)


>Number:         9325
>Category:       optimization
>Synopsis:       wrong conversion of constants: (int)(float)(int) (INT_MAX)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 15 04:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Konstantine Serebriany
>Release:        3.2
>Organization:
>Environment:
Sparc Solaris 2.8 
>Description:
(int)(float)(int)(INT_MAX)
is transformed to INT_MAX, which is incorrect.
Should leave the conversions.

f1() and f2() are optimized wrong, 
while f3() and f4() are ok

/////  file 2_31.c 
extern int printf(const char *, ...);
int f1(){
        return (int)2147483648.0f;
}
int f2(){
        return (int)(float)( 2147483647 );
}
int f3(){
        float a = 2147483648.0f;
        return (int)a;
}
int f4(){
        int a = 2147483647;
        float b = (float)a;
        return (int)b;
}
int main()
{
        printf("%d\n%d\n%d\n%d\n", f1(), f2(), f3(), f4());
        return 0;
}






>How-To-Repeat:
gcc 2_31.c ; a.out
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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