Fucking GCC horror stories

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Fucking GCC horror stories

Post by Arce »

Code: Select all

#ifndef TEST_H
#define TEST_H
#include "qdebug.h"
class test
{
public:
    test();
    test* getInstance(){return NULL;}
    void doShit() { int x=3; qDebug()<<x;}
};

#endif // TEST_H

Code: Select all

    test a;
    test* instance=(test*)a.getInstance();
    instance->doShit();
Not only is there NO runtime error, but the log actually prints "3." Now, go make an abstract factory, very very slightly fuckup your "create" function so that it returns null, and it still "work" (on the surface). Good luck debugging...-.-;

Also, there was a point where i was doing this:

Code: Select all

bool Level::areaExists(QString) {
    for(int i=0;i<areaList.size();i++) {
        if(name.compare(areaList[i]->getName(),Qt::CaseInsensitive) == 0) {
           return true;
        }
    }
    return false;
}
I'd used a similar function in several other places, and just copy-pasted. Well, note how I accidentally didn't give the damned thing a parameter. Apparently, in GCC, that's only a warning and not an error. Couple this with the fact that GCC gives you warnings for "suggested space in 'for(;;)'" as well as other stupid shit...So, what had happened is that this function was always comparing the name of the current level (rather than the one you pass to the function) to the list of Area...Thereby almost always returning false. Since there was no error, I dismissed this quickie function as a possibility in my unexpected results in my load. A few hours later, Falco discovered this bullshit.

Granted, I should not be using the same name for the parameter and private memeber...But still. That is fucking bullshit that GCC would allow me to do that. I literally spent HOURS on gcc's fucking bullshit lack of errors, and I'm pissed.

OH, and here's another:
Add this to the above test.h:

Code: Select all

    bool doMoreShit() {/*k, what?*/}
then this in the driver:

Code: Select all

if(instance->doMoreShit()) /*what happens here?*/;
And you get a simple warning. Not error.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Fucking GCC horror stories

Post by Arce »

I guess the moral here is "fix all of your warnings." Especially on GCC.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Fucking GCC horror stories

Post by K-Bal »

Arce wrote:I guess the moral here is "fix all of your warnings." Especially on GCC.
-Wall -Weffc++ -Werror ... and prefix you member variables ;)
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Re: Fucking GCC horror stories

Post by dejai »

Since we are sharing stories about fail gcc. G++ has a bug where if you try to transform using std::lower it just will not work. Microsofts compiler can do it but g++ cannot.

So transform(str.begin(), str.end(), str.begin(), std::lower); needs to be written as std::transform( s.begin(), s.end(), s.begin(),
std::bind1st( std::mem_fun( &std::ctype<char>::tolower ),
&std::use_facet< std::ctype<char> >( loc ) ) ); at that point I just wrote my own function to turn things to lower case :)
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Fucking GCC horror stories

Post by XianForce »

I remember once, I accidentally passed one too many parameters to a function. And it didn't complain at all, just tried to run it, and then it randomly crashed when it hit that function call.
Post Reply