Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » lol this bug

This thread is locked; no one can reply to it. rss feed Print
lol this bug
Mark Oates
Member #1,146
March 2001
avatar

{"name":"611455","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d37a6646de7f55bd7517750c811cb641.png","w":550,"h":344,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d37a6646de7f55bd7517750c811cb641"}611455

8-)

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig
Member #7,536
July 2006
avatar

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig
Member #7,536
July 2006
avatar

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

But you can reasonably infer it calls assert on a false return. And if you define NDEBUG, it never gets called. Likewise, if EAGLE_DEBUG is not defined, EAGLE_ASSERT compiles away to nothing, hence it's like you never called LoadConfig() at all in release mode.

bamccaig
Member #7,536
July 2006
avatar

Which is only a bug if you know what LoadConfig() does and you know the context of this statement. :P For all we know, it's a unit test for EAGLE_ASSERT. :P

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Dizzy Egg
Member #10,824
March 2009
avatar

#SelectExpand
1 2int iLoop; 3 4... 5 6void checkDat() 7{ 8 for(iLoop = 1;iLoop < 20;iLoop++) 9 { 10 checkBytes(&b); 11 } 12} 13 14void checkBytes(int * b) 15{ 16 for(iLoop = 1;iLoop < 8;iLoop++) 17 { 18 if(b < 1) 19 { 20 printMessage("byte out of range"); 21 } 22 } 23}

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

bamccaig
Member #7,536
July 2006
avatar

If it's an assert, then it's testing a boolean statement. What do you think LoadConfig does but load a configuration? If you don't do it, then obviously you're gonna have problems.

Software development is not the place for assumptions.

Think outside the box bambams.
<box>
</box>

FTFY. :P

Chris Katko
Member #1,881
January 2002
avatar

I've had so many silly bugs before! I just wish I could remember them for here.

For the longest time, (and I posted a thread years ago about this), I never realized (or always forgot!) that C/C++ treat different numbers... as different numbers.

5; //int 5
5.0; //double

5F; //float
5.0F; //float

So I'd run into errors when I combine ints and floats all the time when I have a bunch of multiplies and divides, but no .0, it wipes it all away (or sometimes just hard-to-notice parts) to zero. It also changes based on the position of the arguments.

No C/C++ book I read growing up ever stressed that issue except (at best) showing a simple diagram with no application explanation about implicit conversion rules.

IIRC, D doesn't allow implicit conversion except in the most obvious of cases and will flag it. But it definitely allows it for custom unit types... I don't know. It's been forever since I looked into this problem I used to subtle bugs from all the time.

https://wiki.dlang.org/Implicit_conversions_in_user_types

C#... allows you to define a user-defined implicit conversion? That's... kind of cool though the opposite idea. Never heard of it till I just googled it:

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/implicit

I think the issue pops up the most (or only) when you divide by an int, even when you intend to have float precision. So if you're doing something like dividing by the TILE_WIDTH (int, pixels in a tile) but want the fractional part, it goes poof.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Polybios
Member #12,293
October 2010

I had one bug where I accidentally had typed something like a*+b in a more complex formula all written without spaces :-X. I meant a+b but it took me hours to spot it and I wondered that it was even valid.

l j
Member #10,584
January 2009
avatar

Polybios said:

I had one bug where I accidentally had typed something like a*+b in a more complex formula all written without spaces :-X. I meant a+b but it took me hours to spot it and I wondered that it was even valid.

I think it's valid because there is one binary(multiplication) and one unary(unary +) operator there. Not sure what the unary + operator is useful for though... At least in most languages, in JS it's used to convert a value to a Number.

My most annoying bug is probably where I typed 1 instead of l using a typeface that rendered the characters exactly the same.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

AramisL
Member #16,723
August 2017
avatar

:'( I'm the mother of all the bugs in my programs

Chris Katko
Member #1,881
January 2002
avatar

I Am a Strange Loop

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Peter Hull
Member #1,136
March 2001

How about this one from the set up code for a microcontroller?
{"name":"611457","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0ce42c19bfd4921153a58458715a576d.png","w":462,"h":201,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0ce42c19bfd4921153a58458715a576d"}611457
I didn't make it but I did find it after a lot of staring at the screen. :-/

bamccaig
Member #7,536
July 2006
avatar

Audric
Member #907
January 2001

portb_init is probably the default value for PORTB, but it overwrites PORTA instead.

bamccaig
Member #7,536
July 2006
avatar

Mark Oates
Member #1,146
March 2001
avatar

I didn't make it but I did find it after a lot of staring at the screen. :-/

:D I caught it. It's lol approved.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Go to: