Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#275 closed defect (fixed)

Build error __warn_memset_zero_len

Reported by: Marco Becker Owned by: Maxim Dounin
Priority: minor Milestone:
Component: nginx-module Version: 1.2.x
Keywords: ngx_http_autoindex_module Cc:
uname -a: Linux marco 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.2.6
built by gcc 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configure arguments: --sbin-path=/opt/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/etc/nginx/nginx.pid --prefix=/opt/nginx

Description

I got the following error wehn build the source code with gcc option -O3:

gcc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -O3 -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
		-o objs/src/http/modules/ngx_http_autoindex_module.o \
		src/http/modules/ngx_http_autoindex_module.c
In file included from /usr/include/string.h:642:0,
                 from src/os/unix/ngx_linux_config.h:26,
                 from src/core/ngx_config.h:26,
                 from src/http/modules/ngx_http_autoindex_module.c:8:
In Funktion »memset«,
    eingefügt von »ngx_http_autoindex_handler« bei src/http/modules/ngx_http_autoindex_module.c:492:13:
/usr/include/x86_64-linux-gnu/bits/string3.h:82:30: Fehler: Aufruf von »__warn_memset_zero_len« mit Attributwarnung deklariert: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
cc1: Alle Warnungen werden als Fehler behandelt
make[1]: *** [objs/src/http/modules/ngx_http_autoindex_module.o] Fehler 1
make[1]: Verlasse Verzeichnis '/root/nginx-1.2.6'
make: *** [build] Fehler 2

The ./configure options as follows:

./configure --sbin-path=/opt/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/etc/nginx/nginx.pid --prefix=/opt/nginx --with-cc-opt="-O3"

Attachments (2)

fix-false-memset-warnings.patch (670 bytes ) - added by johnleach.co.uk 11 years ago.
Fix for compilation warning
fix-false-memset-warnings.patch​ (854 bytes ) - added by johnleach.co.uk 11 years ago.
Fix for compilation warning

Download all attachments as: .zip

Change History (9)

comment:1 by Maxim Dounin, 11 years ago

Resolution: wontfix
Status: newclosed

This seems to be a warning incorrectly generated by Linux headers when high optimization levels are used (see 1, 2). As a workaround you may use

./configure --with-cc-opt="-O3 -Wno-error"

to compile with -O3 on Linux.

by johnleach.co.uk, 11 years ago

Fix for compilation warning

comment:2 by johnleach.co.uk, 11 years ago

This patch works around the compile warning without much effort, and it also means we don't have to disable the checking (which is generally useful, and is the default for recent package builds too).

There is no other occurrence of a false positive like this in the codebase btw - this is the only thing I've found that needed a tweak. Any chance it could be merged?

by johnleach.co.uk, 11 years ago

Fix for compilation warning

comment:3 by maxim, 11 years ago

Resolution: wontfix
Status: closedreopened

comment:4 by maxim, 11 years ago

Owner: set to Maxim Dounin
Status: reopenedassigned

Maxim, please take a look at the enclosed patch and decide what to do with it.

comment:5 by Maxim Dounin, 11 years ago

In 5070/nginx:

(The changeset message doesn't reference this ticket)

comment:6 by Maxim Dounin, 11 years ago

Resolution: fixed
Status: assignedclosed

As this is indeed the only warning generated for the code I've committed the patch, slightly modified to better match style and surrounding code. Thanks.

comment:7 by Maxim Dounin, 11 years ago

In 5151/nginx:

(The changeset message doesn't reference this ticket)

Note: See TracTickets for help on using tickets.