bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/6660] New: adjustment to hush warnings about overflow in impli


From: brendan+sourceware at zen dot org
Subject: [Bug gold/6660] New: adjustment to hush warnings about overflow in implicit conversion
Date: 19 Jun 2008 22:40:15 -0000

The 16-bit relocations in powerpc.cc have the line

    val &= ~static_cast<Valtype>(0xffff);

This causes gcc to complain about the fact that the ~ operator causes gcc to
promote to int the result of the Valtype (uint16_t) static_cast, which is then
attempted to be used for the &= assignment:

   ../../src/gold/powerpc.cc:631: warning: overflow in implicit constant 
conversion

This change moves the ~ operation inside the static_cast so the result is 16
bits wide.

B


2008-06-18  Brendan Kehoe  <address@hidden>

        * powerpc.cc (Powerpc_relocate_functions::addr16_ha): Move ~ one-
        complement inside static_cast to avoid promotion to int.
        (Powerpc_relocate_functions::rel16_ha): Likewise.

Index: powerpc.cc
===================================================================
RCS file: /cvs/src/src/gold/powerpc.cc,v
retrieving revision 1.3
diff -u -p -r1.3 powerpc.cc
--- powerpc.cc  18 Jun 2008 22:32:37 -0000      1.3
+++ powerpc.cc  19 Jun 2008 22:22:11 -0000
@@ -605,7 +605,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~static_cast<Valtype>(0xffff);
+    val &= static_cast<Valtype>(~0xffff);
     reloc &= static_cast<Valtype>(0xffff);
 
     elfcpp::Swap<16, true>::writeval(wv, val | reloc);
@@ -628,7 +628,7 @@ public:
       reloc += 0x10000;
     reloc >>= 16;
 
-    val &= ~static_cast<Valtype>(0xffff);
+    val &= static_cast<Valtype>(~0xffff);
     reloc &= static_cast<Valtype>(0xffff);
 
     elfcpp::Swap<16, true>::writeval(wv, val | reloc);

-- 
           Summary: adjustment to hush warnings about overflow in implicit
                    conversion
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P3
         Component: gold
        AssignedTo: ian at airs dot com
        ReportedBy: brendan+sourceware at zen dot org
                CC: bug-binutils at gnu dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=6660

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]