[LLVMbugs] [Bug 11878] New: Narrowing conversion errors in locale.cpp on trunk clang

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jan 28 02:13:19 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=11878

             Bug #: 11878
           Summary: Narrowing conversion errors in locale.cpp on trunk
                    clang
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: pyry.jahkola at iki.fi
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Using a trunk version of clang,

clang version 3.1 (http://llvm.org/git/clang.git
a5ee6345b5af1c88262d02d248e76ad2423161a0)

and having applied the fix to http://llvm.org/bugs/show_bug.cgi?id=11428 as
suggested by Alberto Ganesh Barbati in the discussion, the compilation fails
with the error:

+ clang++ -c -g -Os -arch i386 -arch x86_64 -std=c++0x -fstrict-aliasing -Wall
-Wextra -Wshadow -Wconversion -Wnewline-eof -Wpadded -Wmissing-prototypes
-Wstrict-aliasing=2 -Wstrict-overflow=4 -nostdinc++ -I../include
../src/locale.cpp
../src/locale.cpp:1415:22: error: case value evaluates to -2, which cannot be
narrowed to type
      'size_t' (aka 'unsigned long')
                case -2:
                     ^
../src/locale.cpp:1412:22: error: case value evaluates to -1, which cannot be
narrowed to type
      'size_t' (aka 'unsigned long')
                case -1:
                     ^
../src/locale.cpp:1519:14: error: case value evaluates to -2, which cannot be
narrowed to type
      'size_t' (aka 'unsigned long')
        case -2:
             ^
../src/locale.cpp:1518:14: error: case value evaluates to -1, which cannot be
narrowed to type
      'size_t' (aka 'unsigned long')
        case -1:
             ^
4 errors generated.

Apparently, the fix is to static_cast<size_t>(...) the negative integer
literals on the failing lines. (With these fixes, libcxx compiles on my version
of clang.)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list