[Bug 232072] Parsing error with format "%d" in strptime(3)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Oct 8 14:47:24 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232072

            Bug ID: 232072
           Summary: Parsing error with format "%d" in strptime(3)
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: standards
          Assignee: standards at FreeBSD.org
          Reporter: miguel_tete17 at hotmail.com

the format "%d" in the c function strptime(3) does not conform to what the
documentation says
(https://www.freebsd.org/cgi/man.cgi?query=strptime&sektion=3&manpath=freebsd-release-ports)

It is supposed to allow numbers between "01" and "31" but it also allows "00".
I am not sure if it is a bug or just the FreeBSD way of doing this function.
To my knowledge GNU has the fore mentioned behaviour.

Small c++ code to reproduce the error:

########################################################
#include<iostream>
#include<ctime>

int main()
{
       struct tm tm;
       if(strptime("00", "%d", &tm))
       {
               std::cout << "WRONG" << std::endl;
       }
       else
       {
               std::cout << "OK" << std::endl;
       }
}
########################################################

just execute 
clang++ main.cpp && ./a.out

EXPECTED:
OK

GOT:
WRONG

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-standards mailing list