Created attachment 29874 [details] preprocessed source seen when building OpenJDK-7 on x86_64-linux-gnu, no reduced test case yet. works with 4.6 and 4.8, and a 4.7 branch from march. trying to get one revision. g++-4.7 -fno-rtti -fno-exceptions -fcheck-new -fvisibility=hidden -g -O3 -fno-strict-aliasing -Werror -c g1BlockOffsetTable.ii In file included from /usr/include/string.h:638:0, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp:35, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/utilities/globalDefinitions.hpp:33, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/utilities/debug.hpp:29, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/runtime/globals.hpp:28, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/memory/allocation.hpp:28, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/memory/memRegion.hpp:28, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp:28, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp:28, from /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:26: In function 'void* memset(void*, int, size_t)', inlined from 'void G1BlockOffsetSharedArray::_ZN24G1BlockOffsetSharedArray16set_offset_arrayEmmh.isra.8(unsigned char*, size_t, size_t, unsigned char)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp:169:52, inlined from 'void G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t, size_t)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:195:67, inlined from 'void G1BlockOffsetArray::_ZN18G1BlockOffsetArray31set_remainder_to_point_to_startEP8HeapWordS1_.part.55(HeapWord*, HeapWord*)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:168:61, inlined from 'void G1BlockOffsetArray::set_remainder_to_point_to_start(HeapWord*, HeapWord*)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:369:1, inlined from 'void G1BlockOffsetArray::alloc_block_work2(HeapWord**, size_t*, HeapWord*, HeapWord*)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:510:53, inlined from 'HeapWord* G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord*, HeapWord*, const void*)' at /scratch/packages/openjdk/7u15/openjdk-7-7u17-2.3.8/build/zerovm/openjdk/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp:394:59: /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] /usr/include/x86_64-linux-gnu/bits/string3.h:81:32: error: call to '__warn_memset_zero_len' declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] cc1plus: all warnings being treated as errors
I don't think this is wrong code at all. The warning is correct for the code as given but wrong for memset in general. The code looks like: void set_offset_array(size_t left, size_t right, u_char offset) { ; ; size_t num_cards = right - left + 1; memset(&_offset_array[left], offset, num_cards); } .... num_cards is being turned into 0 which is fine in this case as optimization has happened. The problem is the memset code is just bogus when it tries to see if the length is 0.
Also this is a glibc issue then.