getopt.c: optarg should not be initialized

Eric Blake
Tue Sep 21 23:52:00 GMT 2010

On 09/21/2010 10:11 AM, Christophe Lyon wrote:
> Well, then, why glibc doesn't initialize optarg?

I don't know.  We are free to copy that if we want, but POSIX does not 
require that we copy that.

> The problem I faced is that, being un-initialized in user code,

Why?  If your user code intends to override the libc getopt, then your 
user code must not use anything uninitialized.  Fix your user code - 
just because it happened to work with glibc does not make it correct.

Eric Blake    +1-801-349-2682
Libvirt virtualization library

More information about the Newlib mailing list