Skip to main content
GameDev.net gamedev.net
🔒 Locked

Spot the bug quiz.

Started by boogyman19946 Apr 27, 2015 at 9:36 PM 37 replies 13.4k views
Original Post
boogyman19946
boogyman19946

A friend of mine posted this little quiz on Google+ not too long ago, and I thought you guys might get a kick out of it if you haven't seen it before. I haven't seen C++ code in ages (I'm a Java-based code monkey myself), but I was still able to get some of the questions right. Fair warning: some of the code present is a major eye sore. Not quite THAT bad though.

http://q.viva64.com/

Yo dawg, don't even trip.
MarkS_
MarkS_

That looks fun, but I cannot play on this little phone! Too many instances of me screaming " NO! Not the comma! Arrgh!"

I'll have to wait until I get home.

As to that other link you posted.. O.o Oh. My. God!

Zaoshi Kaba
Zaoshi Kaba

11 / 15.

I assumed it has to be a bug while one of answers was simply a misplaced semicolon. Didn't expect that.

Bacterius
Bacterius

12/15, thought it only gave me 11/15 because in the misplaced bracket question I identified the problem correctly but clicked on the == instead of the misplaced bracket (it seemed reasonable, honestly, that was unfair) so I just gave myself the point. I didn't spot the misplaced semicolon either somehow, goes to show how these things are easy to miss!

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
l0calh05t
l0calh05t

12/15, thought it only gave me 11/15 because in the misplaced bracket question I identified the problem correctly but clicked on the == instead of the misplaced bracket (it seemed reasonable, honestly, that was unfair) so I just gave myself the point. I didn't spot the misplaced semicolon either somehow, goes to show how these things are easy to miss!

Yeah, same thing happened to me. And in one case i misclicked by one character.

frob
frob

Ohh, I earn a title of "Pedant of C++".

Most of those were copy/paste bugs, and their names were pretty bad, or at least looked bad out of context.

Fun little quiz.

boogyman19946
boogyman19946

Ohh, I earn a title of "Pedant of C++".

Most of those were copy/paste bugs, and their names were pretty bad, or at least looked bad out of context.

Fun little quiz.

I thought the same thing to myself. Not to mention, a good chunk of those bugs weren't really C++ specific. They could have happened in any language. For instance, there was a lot of bugs where people wrote

x0 - x1;

y0 - y1;

y0 - z1;

which can literally happen in any language. Some things, however, were classic C++ wtf moments.

Yo dawg, don't even trip.
Nypyren
Nypyren
Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.
alh420
alh420

Nice touch that all the samples come from real life projects, and you even get to know which project :)

Hodgman
Hodgman

Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.

Yeah I gave up on the memcmp(a,b,c == 0) question (which should be memcmp(a,b,c)==0)

My answer was "The ==0 is in the wrong place, it needs to be after the close-parenthesis", so I clicked on the ==.

But then the quiz said "Nope! The close-parenthesis is in the wrong place, it needs to be before the ==".

angry.png

MarkS_
MarkS_


Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.

Yeah I gave up on the memcmp(a,b,c == 0) question (which should be memcmp(a,b,c)==0)

My answer was "The ==0 is in the wrong place, it needs to be after the close-parenthesis", so I clicked on the ==.
But then the quiz said "Nope! The close-parenthesis is in the wrong place, it needs to be before the ==".
angry.png



But the "==" is exactly where it should be! The ")" is out of place! tongue.png
Stefan Fischlschweiger
Stefan Fischlschweiger

2 out of 15 - Should not be allowed near C++ :P

Granted however, I never programmed C++, only a bit of ANSI-C and now I only do C#

slicer4ever
slicer4ever

11/15. an intersting quiz, they do a good job for the most part, except when you have to identify missing pieces of code, and i have to guess which symbol they want me to click to be "correct".

boogyman19946
boogyman19946

Some of those I'm even surprised that I got.

I think there was a question that dealt with local variables being returned from a function by reference. Obviously, that's... a case of a dangling pointer I think, but if you're a Java programmer... what's a dangling pointer? One time I came back to C++ for a quick project, and I'm surprised to this day that I remembered that fact as if I've kept it in mind all this time.

Yo dawg, don't even trip.
swiftcoder
swiftcoder

That's a pretty good way to make the case for static analysis.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Endurion
Endurion

Very nice :)

One or two of these cases had me with their definition of the wrongly placed symbol.

They need to include some famous bugs **cough**goto fail** :)

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
TheChubu
TheChubu

6/15

I really liked it. At first I was going with the mentality of "This is going to be an operator precedence test" so I looked at all the wrong places biggrin.png Then it became clear that it was just a general bugs thing. Really liked the thing about misplaced parenthesis, or bugs in long blocks of similar code.


Obviously, that's... a case of a dangling pointer I think, but if you're a Java programmer... what's a dangling pointer?

Eh if you ever touched any kind of language that lets you use pointers you'll probably remember it. I mean, I didn't got it right but when it said "returning reference to a local variable" I was like "Oh, duh!", I know what it is, I just wasn't looking for it.

Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"   My journals: dustArtemis ECS framework and 
boogyman19946
boogyman19946

Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.

I myself started with C++ I think. It was alright, but knowing what I know now, I don't know if today I wouldn't start with Python first. I don't even like the language, but at my internship Python is the main flavor of the proverbial kool aid. Personally, I find it annoying, but it might be more so because I've been using Java for the vast majority of my programming career. It is by no means a bad language. I'm simply not proficient in it.

Yo dawg, don't even trip.
SmkViper
SmkViper

Then again I advocate learning with something like C or Pascal variants, and only then moving onto managed or scripting languages. Exclusively learning and using managed languages seems like a bad idea to me.


I kind of disagree - starting with a managed or more "scripting-like" language can get the person interested in programming in the first place because of how easy it is to get the computer to do something. You don't have to deal with a lot of the boilerplate ceremony that lower-level languages foist on you. Heck, I started with a BASIC variant as a kid - and while it isn't as high level as something like Python, I could get a simple guess the number game working quickly.

Of course, once you you've got them hooked, then teach them the lower level stuff so their skills improve. Knowing how to code in a lower-level language with manual resource management I think is critical to being a good programmer - but you don't have to start there.
swiftcoder
swiftcoder

Of course, once you you've got them hooked, then teach them the lower level stuff so their skills improve. Knowing how to code in a lower-level language with manual resource management I think is critical to being a good programmer - but you don't have to start there.

I'm of two minds on that - I find that those who start with managed languages tend never to achieve as high a degree of proficiency in lower-level programming.

In a way, I guess it's hard to catch up to someone who cut their teeth on C, assembly and hardware architectures.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.