Bug 15510 - getopt() do NOT REORDER the argv[] when specify the -std=c99 option
Summary: getopt() do NOT REORDER the argv[] when specify the -std=c99 option
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.15
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-21 15:46 UTC by Chopin
Modified: 2014-06-13 17:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
the source code, complie it with and without -std=c99 to see the difference (431 bytes, application/octet-stream)
2013-05-21 15:46 UTC, Chopin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chopin 2013-05-21 15:46:24 UTC
Created attachment 7035 [details]
the source code,  complie it with and without -std=c99 to see the difference

using the code show in getopt(3), complie it using gcc c99 option(-std=c99), then if we input like this:
./a.out name -t 10
the getopt() can not find the -t option and its value. it just stop at name.

but if we complie it without -std=c99, things get right, we will get the -t and its value, and name is reorder at last position.
Comment 1 Andreas Schwab 2013-05-21 17:00:37 UTC
To get the GNU style getopt use <getopt.h> or define _GNU_SOURCE.
Comment 2 OndrejBilka 2013-06-11 16:18:38 UTC
Closing as Andreas pointed out.