![]() |
|
We must post bugs and squash them*** |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Bugz everywhere!!! I must squash them! Spot the bug : for (unsigned int i = (unsigned int)((int)list.size() - 1) ; i >= 0 ; --i) { printf("%u\n" , i); }
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
MiquelFire
Member #3,110
January 2003
![]() |
If size() returns 0, then i would be 4 billion (too lazy to look up the number), assuming the cast to unsigned treats negative numbers that way. I feel like that's not the bug you're asking us to find though. --- |
SiegeLord
Member #7,827
October 2006
![]() |
#include <SDL2/SDL.h> #include <SDL2/SDL_timer.h> int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window* win = SDL_CreateWindow("Welcome to SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1000, 1000, 0); SDL_Delay(2000); }
"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
DarĂo B.
Member #16,705
July 2017
![]() |
When i reaches 0 and it substracts 1, it wraps around to the maximum value of unsigned int. Therefore, the loop never ends.
|
Peter Hull
Member #1,136
March 2001
|
GCC knows! Quote: <source>:4:43: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits] (strangely, clang does too but it's not reported, even with -W -Wall)
|
Elias
Member #358
May 2000
|
SiegeLord said:
SDL_Init(SDL_INIT_EVERYTHING);
Ohhh, can we have al_init_everything()? Instead of:
Maybe with a bonus version that also creates a display and timer and event queue with everything attached, and a call to al_reserve_samples? queue = al_init_everything_ex(1280, 720, 60); // can get the created display with al_get_current_display()
-- |
Erin Maus
Member #7,537
July 2006
![]() |
1#call-to-action button {
2 border: none;
3 outline: none;
4
5 width: 320px;
6
7 font-family: inherit;
8 font-size: 3.5rem;
9
10 color: #eeeeee;
11 text-shadow: 1px 1px #000000;
12
13 background: none;
14 border-image: url('border3.png') 24 24 fill / 24px 24px repeat;
15}
16
17#call-to-action button::before {
18 visibility: hidden;
19 position: absolute;
20 content: url('border3.png') url('border3-hover.png') url('border3-active.png');
21}
22
23#call-to-action button:hover {
24 color: #ffffff;
25 text-shadow: 1px 1px #000000;
26
27 border-image: url('border3-hover.png') 24 24 fill / 24px 24px repeat;
28}
29
30#call-to-action button:active {
31 color: #dddddd;
32 border-image: url('border3-active.png') 24 24 fill / 24px 24px repeat;
33}
That #call-to-action button::before to prevent image loading when hover/clicked causing a very brief flicker... --- |
DanielH
Member #934
January 2001
![]() |
You can do what I did. I wrapped them up in a function and used flags. //pseudo code int init(int flags) { if (!al_init()) return -1 if (flag & FLAG_IMAGE_ADDON) ... }
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
The correct code would have been : for (unsigned int i = list.size() ; i > 0 ; --i) { printf("%i\n" , (int)i - 1; } It's not often you see underflows, but they're there. EDIT Allegro5System* a5sys = GetAllegro5System(); if (EAGLE_FULL_SETUP != a5sys->Initialize(EAGLE_FULL_SETUP) { EagleWarn() << "Not all modules initialized. Warning.\n"; } EagleGraphicsContext* win = a5sys->CreateGraphicsContext(800,600 , EAGLE_WINDOWED | EAGLE_OPENGL); if (!(win && win->Valid())) { EagleCritical() << "Failed to create window.\n"; } 3 line setup for a window. It serves me right. No more lame queue creation and registration every time you want a window with input. Multiple thread safe windows and more. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Dizzy Egg
Member #10,824
March 2009
![]() |
---------------------------------------------------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
That was not an example of a bug, just init code. Post your bugs! My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
{"name":"612991","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/8\/88c3874f8b5efb365312ba84dabe7fe5.png","w":462,"h":201,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/8\/88c3874f8b5efb365312ba84dabe7fe5"}
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Sweet. Hope that microcontroller didn't do anything important. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Polybios
Member #12,293
October 2010
|
Elias said: Ohhh, can we have al_init_everything()
Then I also want al_destroy_everything() |
Peter Hull
Member #1,136
March 2001
|
Polybios said: Then I also want al_destroy_everything() That exists but only people above our pay-grade are allowed to used it. Here's a bit of a shocker that I did not know about until today, from man abs SYNOPSIS #include <stdlib.h> int abs(int i); DESCRIPTION The abs() function computes the absolute value of the integer i. RETURN VALUES The abs() function returns the absolute value. So far, so good, but then: BUGS The absolute value of the most negative integer remains negative.
|
MiquelFire
Member #3,110
January 2003
![]() |
That's because signed integers have an extra negative number compared to positive numbers, for example, for an 8 bit value, we have -128 to 127. --- |
Peter Hull
Member #1,136
March 2001
|
MiquelFire said: That's because signed integers have an extra negative number compared to positive numbers, for example, for an 8 bit value, we have -128 to 127. You know this and I know this. But I'm sure I've never written code to account for it x = abs(x); if (x >= 0) { something(x); } else { error(); } I don't think there's a better option either, returning zero or INT_MAX or anything else would also lead to silent errors. And C doesn't usually raise a signal for integer arithmetic (? does it?)
|
MiquelFire
Member #3,110
January 2003
![]() |
I'm trying to think if a way in which the negative number issue with abs would matter anyway. With signed 8-bit, if -128 is a possible value, what's stopping you from getting -150 before you call abs? I think the times you need to worry about the minimum number being passed to abs, you have to worry about the value being out of range for the integer type you are using anyway. --- |
|