stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-945) [Sun C++] truncwarn on safe conversion
Date Fri, 23 May 2008 17:47:55 GMT
[Sun C++] truncwarn on safe conversion
--------------------------------------

                 Key: STDCXX-945
                 URL: https://issues.apache.org/jira/browse/STDCXX-945
             Project: C++ Standard Library
          Issue Type: Bug
          Components: External
            Reporter: Martin Sebor


Dear Sun Studio Developer,

Thank you for your interest in improving the quality of Sun Studio 
product.

Your report has been assigned an internal review ID of  1254911.

Please be aware that the large volume of reports we receive sometimes 
prevents us from responding individually to each message.

If the information is determined to be a new Bug or Request for 
Enhancement (RFE), or a duplicate of a known Bug or RFE, you will 
receive a followup email containing a seven digit bug number.  By 
using this seven digit bug number, you may search for, view, or vote 
for this bug in the Bug Database at http://bugs.sun.com/.  Please note 
that we cannot promise to fix all reported bugs.

If you just reported an issue that could have a major impact on your 
project and require a timely response, please consider purchasing 
one of the support offerings described at 
http://developers.sun.com/prodtech/cc/support/support_services.jsp.

The Sun Developer Network (http://developers.sun.com) is a free service 
that Sun offers. To join, visit http://developers.sun.com/global/join_sdn.html.

Regards,
Sun Studio Developer Bug Report Review Team



---------------------------------------------------------------


Date Created: Fri May 23 11:23:54 MDT 2008
Type:        bug
Customer Name:   Martin Sebor
Customer Email:  sebor AT roguewave DOT com
SDN ID:       
status:      Waiting
Category:    c++
Subcategory: other
Company:     Rogue Wave Software
release:     studio12
hardware:    sun4
OSversion:   solaris_10
priority:    4
Synopsis:    truncwarn on safe code
Description:
 FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Solaris 10

A DESCRIPTION OF THE PROBLEM :
The compiler issues conversion warnings for obviously safe code. For instance, the initialization:
on line 2 below cannot cause truncation since the result of the & operator is guaranteed
to be in range of unsigned int (on both ILP32 and LP64), even though the type of the initializer
expression is wider than the object under initialization.
{noformat}
    /* 1 */ unsigned long  a = 0;
    /* 2 */ unsigned int   b = a & 0xffffffff;
{noformat}
The compiler should detect these cases and avoid issuing warnings for them.

In addition, as the Error Message(s) show, all the warnings are unnecessarily duplicated.

Finally, declaring each object const silences the warnings. The warnings should be issued
consistently, regardless of any cv-qualifiers.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile attached program as follows:
{noformat}
CC +w -m64 -V u.cpp
{noformat}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No conversion (truncation) warnings.
ACTUAL -
Conversion (truncation) warnings.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
{noformat}
CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
/amd/packages/mdx/solaris/amd64/compilers/sun/C++5.9j1/prod/bin/c++filt: Sun C++ 5.9 SunOS_i386
2007/05/03
ccfe: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
"u.cpp", line 4: Warning: Conversion of 64 bit type value to "const unsigned" causes truncation.
"u.cpp", line 4: Warning: Conversion of 64 bit type value to "const unsigned" causes truncation.
"u.cpp", line 5: Warning: Conversion of 64 bit type value to "const unsigned short" causes
truncation.
"u.cpp", line 5: Warning: Conversion of 64 bit type value to "const unsigned short" causes
truncation.
"u.cpp", line 6: Warning: Conversion of 64 bit type value to "const unsigned char" causes
truncation.
"u.cpp", line 6: Warning: Conversion of 64 bit type value to "const unsigned char" causes
truncation.
6 Warning(s) detected.
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482
{noformat}

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
{noformat}
int main ()
{
    /* const */ unsigned long  a = 0;
    const unsigned int   b = a & 0xffffffff;
    const unsigned short c = a & 0xffff;
    const unsigned char  d = a & 0xff;
}
{noformat}
---------- END SOURCE ----------
workaround:  
comments:    (company - Rogue Wave Software , email - sebor@roguewave.com)



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message