ValhallaTeam / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Intermediate.cpp does not compile with -Wshorten-64-to-32 #403

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile ANGLE with clang with -Wshorten-64-to-32 warning enabled.

What is the expected output? What do you see instead?
Expected no warnings.  Got warnings.

What version of the product are you using? On what operating system?
ANGLE r1641 merged into the WebKit project.

Please provide any additional information below.

Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp:1458:61: error: implicit 
conversion loses integer precision: 'size_type' (aka 'unsigned long') to 
'unsigned int' [-Werror,-Wshorten-64-to-32]
    khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length());
                              ~                             ^~~~~~~~~~~~~
1 error generated.

The hashFunction variable is defined as:

typedef khronos_uint64_t (*ShHashFunction64)(const char*, unsigned int);

TString::length() returns a size_t.

See also ANGLE Issue 396.

Original issue reported on code.google.com by ddkilzer@gmail.com on 27 Jan 2013 at 1:03

GoogleCodeExporter commented 9 years ago
I didn't see any hash functions defined in ANGLE, so it seems unlikely that the 
definition could be changed within ANGLE.

The most obvious fix is to use a static_cast which would reduce the size of the 
input string used in the hash function to a maximum of 4,294,967,295 characters:

    khronos_uint64_t number = (*hashFunction)(name.c_str(), static_cast<unsigned int>(name.length()));

Original comment by ddkilzer@gmail.com on 27 Jan 2013 at 1:17

GoogleCodeExporter commented 9 years ago

Original comment by kbr@chromium.org on 7 Feb 2013 at 1:13

GoogleCodeExporter commented 9 years ago

Original comment by kbr@chromium.org on 7 Feb 2013 at 1:30

GoogleCodeExporter commented 9 years ago
Fixed in https://code.google.com/p/angleproject/source/detail?r=1826 .

Original comment by kbr@chromium.org on 12 Feb 2013 at 3:10