The following strings succeeds to parse when FASTFLOAT_ALLOWS_LEADING_PLUS is defined:
"-+nan" // parsed as nan
"-+nan(abc)" // parsed as nan
"-+inf" // parsed as -inf
"-+infinity" // parsed as -inf
Mixing both - and + should result in an error.
To resolve this, replace:
bool minusSign = false;
if (*first ==
UC('-')) { // assume first < last, so dereference without checks;
// C++17 20.19.3.(7.1) explicitly forbids '+' here
minusSign = true;
++first;
}
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
if (*first == UC('+')) {
++first;
}
#endif
with:
bool minusSign = (*first == UC('-'));
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
if ((*first == UC('-')) || (*first == UC('+'))) {
#else
if (*first == UC('-')) {
#endif
++first;
}
I'll create a PR with fix and additional tests.