myzhan / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

src/malloc_hook_mmap_linux.h fails to compile with clang in C++11 mode when targeting 32 bit with _FILE_OFFSET_BITS=64 #683

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile malloc_hook_mmap_linux.h with clang, where CXXFLAGS contains 
-std=c++11 -m32 -D_FILE_OFFSET_BITS=64
2.
3.

What is the expected output? What do you see instead?
The file should compile normally, instead, the following diagnostic is issued 
by clang:

gperftools-2.2/src/malloc_hook_mmap_linux.h:108:23: error:
      non-constant-expression cannot be narrowed from type 'off_t' (aka 'long long') to 'int32'
      (aka 'int') in initializer list [-Wc++11-narrowing]
                      (off_t) offset };
                      ^~~~~~~~~~~~~~
src/third_party/gperftools-2.2/src/malloc_hook_mmap_linux.h:108:23: note: 
insert an explicit cast
      to silence this issue
                      (off_t) offset };
                      ^~~~~~~~~~~~~~
                      static_cast<int32>( )
1 error generated.

What version of the product are you using? On what operating system?
gperftools-2.2 on linux, as vendored into mongodb. Please see 
https://jira.mongodb.org/browse/SERVER-17447 for additional motivation.

In particular, this comment: 
https://jira.mongodb.org/browse/SERVER-17447?focusedCommentId=842439&page=com.at
lassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-842439

The file appears to be unchanged between gperftools-2.2 and gperftools-2.4.

Please provide any additional information below.

> clang --version
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 
3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

> uname -a
Linux workstation 3.16.0-34-generic #47-Ubuntu SMP Fri Apr 10 18:02:58 UTC 2015 
x86_64 x86_64 x86_64 GNU/Linux

Original issue reported on code.google.com by andrew.m...@10gen.com on 22 Apr 2015 at 10:09

GoogleCodeExporter commented 9 years ago
Merged a fix. Thanks.

Original comment by alkondratenko on 3 May 2015 at 9:09