gdl
gdl copied to clipboard
several bugs in TIMESTAMP()
I found by chance several bugs in TIMESTAMP(). In fact a test in test_timestamp.pro
was not OK in IDL ... then I made others tests ... I am rewriting too the tests
E.g. :
IDL> TIMESTAMP(year=2023, day=1)
2023-02-01
...
GDL> TIMESTAMP(YEAR=2023, day=1)
2023-02-01T00:00:00Z
((nevertheless I do not consider this problem as super urgent ...))
The more I go in tests, the more I found bugs ...
The by chance was in fact a warning from my compiler saying
/home/alaingdl/GDL/minimini/src/basic_fun_cl.cpp: In function ‘BaseGDL* lib::timestamp(EnvT*)’:
/home/alaingdl/GDL/minimini/src/basic_fun_cl.cpp:437:45: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
437 | snprintf(timestamp + 20,3, "%.3s", milli);
| ^
Changing the first "3" into "4" is enough for that point. I plan to do that in the code before any bigger change in the bugs.
aside security, another positive effect of using snprintf :smile: . I was counting on the compiler of the GH continuous integration tests to show such problems, but no. What compiler option do you use? It would be useful to have the GH compilation show that kind of warning.