I did say language and tools. ;)
That the language still allows you to make that exact same mistake in exactly the same way doesn't make it look like an upgrade =P
True, the tools for the language are what's better.
I did say language and tools. ;)
That the language still allows you to make that exact same mistake in exactly the same way doesn't make it look like an upgrade =P
True, the tools for the language are what's better.
Oh gee.
Actually, the implicit NULL conversion to literal 0 in my code is a total red herring. The actual evil is squarely with default parameters, and can be trivially reconstructed even with all the parameters being of primitive non-pointer types.Oh, don't worry on that account, we already upgraded our language.
Which, incidentally, also solves ApochPiQ's bug in the post above this.
You know, I'm sure with a higher than default warning level and 'warnings as errors' I've seen the compiler catch this error before now (reports as a warning, warning as error fails the compile).It looks like C#.
I did say language and tools. ;)
Oh, don't worry on that account, we already upgraded our language.
Which, incidentally, also solves ApochPiQ's bug in the post above this.
auto it = std::begin(someContainer);
auto end = std::end(someContainer);
bool found = false;
while(it != end && !found)
{
found = *it == searchItem;
}
Opps...
@ApochPiQ: Then I fail, cause I can't spot it at all.
(Ignoring the lack of actual inheritance in the structs, which I presume isn't the bug)
struct Base
{
Base(int oldValue, int newValueWeJustAdded, int oldValueWithDefault = 42);
};
struct EverythingMustBeOne : Base
{
EverythingMustBeOne()
: Base(1, 1, 1)
{ }
};
struct EverythingMustBeTwo : Base
{
EverythingMustBeTwo()
: Base(2, 2)
{ }
};
Assume that Extremely Bad Things™ happen if the value of oldValueWithDefault in EverythingMustBeTwo is not 2.
You know, I'm sure with a higher than default warning level and 'warnings as errors' I've seen the compiler catch this error before now (reports as a warning, warning as error fails the compile).
Gcc requires -Wall and -extra to catch it. Clang catches it by default.
(incidentally, this discussion is occurring over here as well).
Now, it won't catch you when you make this mistake...Opps...auto it = std::begin(someContainer); auto end = std::end(someContainer); bool found = false; while(it != end && !found) { found = *it == searchItem; }
Lesson: stick to for loops when doing that kind of iterations.
I prefer the 'while' construct; imo it better expresses the intent of the loop.Lesson: stick to for loops when doing that kind of iterations.
If werent by gamedev...Ive had gave up on programming many times..(learned new stuff in that one)