dbetz / propeller-gcc

A port of GCC to the Parallax Propeller
GNU General Public License v3.0
8 stars 4 forks source link

GCC 6.0 bug? #5

Closed DavidZemon closed 8 years ago

DavidZemon commented 8 years ago

I'd like to say it's a bug in 6.0, but it's certainly possible that there's a bug in my code as well. All I know is that build 2408 compiles my code in such a way that it runs correctly, and the latest 6.0 build (from my build server) does not.

The code I'm testing is this example:

#include <PropWare/printer/printer.h>
#include <PropWare/filesystem/sd.h>
#include <PropWare/filesystem/fat/fatfilereader.h>

using namespace PropWare;

int main() {
    const SD driver;
    FatFS    filesystem(&driver);
    filesystem.mount();

    FatFileReader reader(filesystem, "fat_test.txt");
    reader.open();

    while (!reader.eof())
        pwOut << reader.get_char();

    return 0;
}

I understand that's not much help since it includes a lot of unknowns. I worked through it a bit to try and narrow down what is causing the issue, and here's what I found out:

This doesn't work (and by that, I mean nothing is printed to the terminal. nothing at all - even the first "Hello" line)

#include <PropWare/printer/printer.h>
#include <PropWare/filesystem/sd.h>
#include <PropWare/filesystem/fat/fatfilereader.h>

using namespace PropWare;

int main() {
    pwOut << "Hello\n";
    const SD driver;
    pwOut << "Hello\n";
    FatFS    filesystem(&driver);
    pwOut << "Hello\n";

    return 0;
}

And this does (all three "Hello"s are printed)

#include <PropWare/printer/printer.h>
#include <PropWare/filesystem/sd.h>
#include <PropWare/filesystem/fat/fatfilereader.h>

using namespace PropWare;

int main() {
    pwOut << "Hello\n";
    const SD driver;
    pwOut << "Hello\n";
    //FatFS    filesystem(&driver);
    pwOut << "Hello\n";

    return 0;
}

I commented out the constructor for both FatFS and Filesystem (parent class to FatFS) such that they were quite trivial, and it didn't help.

DavidZemon commented 8 years ago

I've confirmed this issue exists in the GCC4 branch as well. Digging into it more now and can hopefully report something more useful soon

DavidZemon commented 8 years ago

It might have something to do with pure-virtual functions. I copied the problem out of the PropWare main project and into a standalone project to try and replicate the issue, but it has vanished. The binary size also shrank from 15k to 10k... The search continues...

DavidZemon commented 8 years ago

Found the problem. I had mistakenly added -fno-exceptions to my scratch project, even though it wasn't part of PropWare's build system. With that extra compile flag, the program now works. I'm adding that flag to PropWare as a standard option now.

I don't know if this is a bug in PropGCC or not... something tells me not, so I'm closing this. Feel free to re-open if you think otherwise and I can provide more details.