Bug 56966 - [4.7 Regression] wrong warning with -Werror (wrong code without Werror?)
Summary: [4.7 Regression] wrong warning with -Werror (wrong code without Werror?)
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, wrong-code
Depends on:
Blocks:
 
Reported: 2013-04-15 13:32 UTC by Matthias Klose
Modified: 2013-05-15 13:32 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.6.4, 4.7.2, 4.8.0
Known to fail: 4.7.3
Last reconfirmed:


Attachments
preprocessed source (241.69 KB, application/x-xz)
2013-04-15 13:32 UTC, Matthias Klose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2013-04-15 13:32:33 UTC
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
Comment 1 Andrew Pinski 2013-04-15 17:34:20 UTC
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.
Comment 2 Richard Biener 2013-05-15 13:32:56 UTC
Also this is a glibc issue then.