Bug 2916

Summary: Command Line Parser treats uint8_t as char
Product: ns-3 Reporter: Jörg Christian Kirchhof <christian.kirchhof>
Component: coreAssignee: Peter Barnes <pdbarnes>
Status: RESOLVED MOVED    
Severity: normal CC: ns-bugs, sebastien.deronne, tomh
Priority: P3    
Version: ns-3.28   
Hardware: All   
OS: All   
See Also: https://www.nsnam.org/bugzilla/show_bug.cgi?id=2904

Description Jörg Christian Kirchhof 2018-05-02 07:55:01 EDT
Overview:
The CommandLine parser treats uint8_t as char. Therefore uint8_t variables get treated unintuitively.

Steps to Reproduce: 
1) Create a script that uses a uint8_t command line argument:
int
main (int argc, char *argv[]) 
{
  uint8_t seed = 0;
  CommandLine cmd;
  cmd.AddValue ("value", "Some Explanation", seed);
  cmd.Parse (argc, argv);
}
2) Run the script with the argument "--value=1"

Actual Results: 
cmd.Parse (argc, argv) sets seed to 49, because 49 is the ASCII value of character '1'.

Expected Results: 
cmd.Parse (argc, argv) should set seed to 1.

Build Date & Hardware: 
ns-3.28 on Mac OS X High Sierra.

Additional Information: 
none.
Comment 1 sebastien.deronne 2020-04-07 05:33:36 EDT
It would worth to port this one to Gitlab, I've faced this problem again.
Comment 2 Peter Barnes 2020-04-08 20:39:11 EDT
Already there :)  See
https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/235