Spot the error?
Uncategorized
2
Posts
1
Posters
7
Views
-
Spot the error?
std::string val = get_string_value();
if (not val.empty())
{
if (val[0] < 0 or val[0] > 9)
{
std::cout << "must start with a digit" << std::endl; -
R relay@relay.mycrowd.ca shared this topic
-
Spot the error?
std::string val = get_string_value();
if (not val.empty())
{
if (val[0] < 0 or val[0] > 9)
{
std::cout << "must start with a digit" << std::endl;And in case anyone tries to bring it up, keywords like "and", "not", "or" and many more have been part of the C standard since 1994 and C++ since 1998.
That is not a bug!
But it is true that many C and C++ developers don't know this is perfectly valid.
The code above contains a very real bug I spent time hunting down tonight in that large codebase I've been looking into recently.
-
R relay@relay.infosec.exchange shared this topic