This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug string/25399] New: undefined reference to `__warn_memset_zero_len' when changing gnuc version
- From: "sguelton at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 16 Jan 2020 10:41:37 +0000
- Subject: [Bug string/25399] New: undefined reference to `__warn_memset_zero_len' when changing gnuc version
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=25399
Bug ID: 25399
Summary: undefined reference to `__warn_memset_zero_len' when
changing gnuc version
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: string
Assignee: unassigned at sourceware dot org
Reporter: sguelton at redhat dot com
Target Milestone: ---
When compiling the following program
```
#undef __GNUC__
#define __GNUC__ 4
#undef __GNUC_MINOR__
#define __GNUC_MINOR__ 9
#include <string.h>
char a[64];
int main ()
{
memset (a, 64, 0);
return 0;
}
```
with a decent gcc version (8.3) and glibc version (2.28), I get a link error
```
gcc a.c -D_FORTIFY_SOURCE=2 -O2
In file included from /usr/include/string.h:494,
from a.c:6:
In function ‘memset’,
inlined from ‘main’ at a.c:10:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:67:7: warning: call to
‘__warn_memset_zero_len’ declared with attribute warning: memset used with
constant zero length parameter; this could be due to transposed parameters
__warn_memset_zero_len ();
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc7RDLx1.o: in function `main':
a.c:(.text.startup+0x5): undefined reference to `__warn_memset_zero_len'
collect2: error: ld returned 1 exit status
```
No link error if I don't force the __GNUC__ and __GNUC_MINOR__.
I've checked the source of glibc-2.30, and the problem seems related to
```
#if !__GNUC_PREREQ (5,0)
__warndecl (__warn_memset_zero_len,
"memset used with constant zero length parameter; this could be due to
transposed parameters");
#endif
```
while `__warn_memset_zero_len` is not defined elsewhere.
In addition to binding glibc to some gcc version, it is also a problem for
non-gcc compilers, like clang, which set GNU C version to 3.2 by default (see
for instance https://reviews.llvm.org/D71082#1822925)
--
You are receiving this mail because:
You are on the CC list for the bug.