[systemd-devel] Compile errors with -Og

Lennart Poettering lennart at poettering.net
Tue Jul 16 17:54:01 PDT 2013


On Wed, 12.06.13 13:02, Jan Janssen (medhefgo at web.de) wrote:

> Hi,
> 
> I just tried compiling with -Og and I get these compiler errors.
> Those don't appear with any other optimization level, so I'm
> suspecting a compiler but here. But since I'm no C expert, I thought
> it would be best if I share this here to see if I'm right about this
> or whether this just shows some subtle bug in the code.
> 
> This is on a up-to-date arch box (gcc 4.8.1) and "make clean"
> run before trying to compile.
> 
> Jan
> 
> ---
>   CC       src/shared/util.lo
> src/shared/util.c: In function 'safe_atod':
> src/shared/util.c:383:16: warning: 'd' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>          *ret_d = (double) d;

Seems your gcc is confused by our RUN_WITH_LOCALE() magic macro, because
it contains a for() loop that it thinks might not be run, but actually
always is.

I added an initialization that should make sure the warning goes away.

>                 ^
> In file included from /usr/include/fcntl.h:296:0,
>                  from src/shared/util.c:35:
> In function 'open',
>     inlined from 'open_terminal' at src/shared/util.c:1834:20:
> /usr/include/bits/fcntl2.h:50:24: error: call to
> '__open_missing_mode' declared with attribute error: open with
> O_CREAT in second argument needs 3 arguments
>     __open_missing_mode ();

Hmm, gcc is confused if we invoke open() with no mode argument but flags
seeded from a variable. Added a work-around for this.

> In file included from /usr/include/fcntl.h:296:0,
>                  from src/shared/util.c:35:
> In function 'openat',
>     inlined from 'xopendirat' at src/shared/util.c:3478:13:
> /usr/include/bits/fcntl2.h:126:26: error: call to
> '__openat_missing_mode' declared with attribute error: openat with
> O_CREAT in third argument needs 4 arguments
>     __openat_missing_mode ();

Same here.
>                           ^
> src/shared/util.c: In function 'create_tmp_dir':
> src/shared/util.c:5718:12: warning: 'd' may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>          dt = strjoin(d, "/tmp", NULL);

Your gcc also doesn't like our RUN_WITH_UMASK macro either, also fixed.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list