/>
X

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.
mary-jo-foley

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

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.

Related

A United Airlines pilot made a big speech to passengers. Not everyone will love it
screen-shot-2022-08-09-at-9-39-33-am.png

A United Airlines pilot made a big speech to passengers. Not everyone will love it

Business
Why you should really stop charging your phone overnight
iphone-charging.jpg

Why you should really stop charging your phone overnight

iPhone
How to get Photoshop for free
photoshop free trial

How to get Photoshop for free

Photo & Video