Microsoft to developers: How to swat potential leap-year bugs

As 2016 is a leap year, what's a C or C++ developer to do to head off potential problems? A new Azure blog post has some tips and guidance.

There's a useful post on Microsoft's Azure blog with some reminders to developers about preparing for possible bugs in their code due to 2016 being a leap year.

leapyearbugs.jpg

Among the areas developers need to watch, according to the February 2, 2016 post from Senior Software Engineer Matt Johnson:

  • Off-by-one issues, especially around data filtering using date-range queries
  • Unexpected or undesired behavior in user interfaces
  • Potential for exceptions, crashes, or hanging as edge cases are encountered

Designers, meet developers: The secret to keeping a development project on the rails

If there's one thing that will knock a development project off track, then it's a communication breakdown between developers and designers - but it's not an intractable problem.

Johnson notes that unit testing isn't likely to be enough in many cases. Whether devs' code runs in the cloud or not, problems still may arise. (Don't forget Azure had a leap-year-related outage of its own in 2012, he reminds readers.)

"Leap year bugs can be found anywhere, in any language, but are most dangerous in C / C++ code, where they can cause application crashes or buffer overflows (which are a security risk)," he notes.

Code that involves adding or subtracting years in C/C++ and declaring an array of values for each day of the year are both susceptible to leap-year issues, he says.

February 29 isn't the only day affected by leap year. December 31, which is the 366th day of the year, can be, too, Johnson reminds devs. Devs need to scrutinize their code; learn how to "mock th clock" in their unit tests; and test year-round, not just before leap years, he advises.

There are more guidance and tips in Johnson's full "Is your code ready for the leap year?" post.

Newsletters

You have been successfully signed up. To sign up for more newsletters or to manage your account, visit the Newsletter Subscription Center.
Subscription failed.
See All
See All