Sunday, August 04, 2013

Bug guys: string extensions and const fields

I love bugs. (No, not like that.) It's always interesting to see how things go wrong; as a language designer I want to learn how to make languages less bug-prone, and as a creator of static analysis tools, I want to learn how to detect hard-to-find-but-real bugs.

As I mentioned a while back, we're starting a new series on the Coverity Development Testing blog to share knowledge of interesting bugs, language quirks and so on. The first episode of Ask The Bug Guys is posted now. In this episode I take on two questions: first, why can't you declare a const field of type parameter type? And second, why does overload resolution sometimes choose an unexpected method when an extension method on strings is available? Thanks to contributors Marcin and Adam for two interesting questions.

If you have questions about strange behavior in your C, C++, C# or Java programs, please email your questions (along with a concise reproducer of the problem) to TheBugGuys@coverity.com. We'll be posting our next set of responses in about two weeks.

QR: Inline image 1