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

3 compiler bugs in one month...

Started by l0calh05t Sep 17, 2015 at 11:49 AM 15 replies 5.8k views
Original Post
l0calh05t
l0calh05t

Well this is fun. Usually, when others (esp. junior programmers) tell me there must be a bug in the compiler, I tell them to check their code first, because it's usually related to undefined behavior. This month, however, I managed to run into a grand total of 3 actual compiler bugs. One in GCC, two in Visual Studio.

  1. GCC can't handle thread_local variables captured by a generic lambda ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67436 )
  2. Visual Studio only generates one virtual function table if there is more than one anonymous member struct ( http://stackoverflow.com/questions/2082339/virtual-tables-on-anonymous-classes )
  3. Visual Studio (up to and including VS2013) can't deal with range-based for loops directly followed by a do { } while, which can easily occur due to a macro ( https://connect.microsoft.com/VisualStudio/feedback/details/855078 )

And in fact I encountered the latter two today. And it's only 2 PM.

ferrous
ferrous

I think you should quit while your ahead, maybe head to the pub.

Radikalizm
Radikalizm

In our current project at work we've seen about 3 or 4 "Internal compiler error" bugs in MSVC over the last three months. This was all legal C++ code mind you, so it was a pain to find workarounds which MSVC would accept without throwing up all over itself.

I gets all your texture budgets!
smr
smr
We're the last two C++ errors?
l0calh05t
l0calh05t

In our current project at work we've seen about 3 or 4 "Internal compiler error" bugs in MSVC over the last three months. This was all legal C++ code mind you, so it was a pain to find workarounds which MSVC would accept without throwing up all over itself.

Had, a few of those and out of memory errors as well. Usually a rebuild solves them, but sometimes they can be a little more persistent. Also very annoying: Linker warnings due to excessively long symbols (which happens all too often with templates and MSVCs very limited symbol lengths...)

We're the last two C++ errors?

All three are related to using C++. If you meant if they are bugs in the C++ standard, no, just bugs in MSVC.

Juliean
Juliean

I've encountered just one, which existed in VS2013 up to and including first SP I belive. Having a double initializer-list like this:


const ecs::ComponentDeclaration::AttributeVector vAttributes =
{
    { L"Positioning", PositioningMode::NORMAL, offsetof(Character, positioning) },
    { L"ZOffset", core::generateTypeId<int>(), offsetof(Character, zOffset) }
};

Somehow caused the destructor of the first element being called twice (when doubling the array), resulting in a crash. The newer service packs fixed that, though.

EDIT: I originally made a thread about it:

http://www.gamedev.net/topic/660049-destructor-in-vector-called-too-often/

Was quite obnoxious because it was not appearent that it was a compiler bug.

smr
smr
Yeah I just wasn't sure if they were C#/VB errors. MS built a new compiler for 4.6 and I have heard about some bugs, at least one pretty serious (something about changing arguments to method calls in some circumstances).
Radikalizm
Radikalizm




Had, a few of those and out of memory errors as well. Usually a rebuild solves them, but sometimes they can be a little more persistent. Also very annoying: Linker warnings due to excessively long symbols (which happens all too often with templates and MSVCs very limited symbol lengths...)

Sadly enough rebuilds never fixed these issues for us. We did see a ton of out of memory errors though, it's not uncommon to see MSVC run out of heap space.

It's always a lot of fun to see a new engineer roll on to the project and encounter this issue, one can only wonder what it's using all that memory for.

I gets all your texture budgets!
frob
frob




one can only wonder what it's using all that memory for

Expanding all the options for templates.

Lots and lots of potentially valid expansions.

l0calh05t
l0calh05t

one can only wonder what it's using all that memory for

Expanding all the options for templates.

Lots and lots of potentially valid expansions.

Other compilers manage without so many issues.

Aside from that, name lookup in templates is FUBAR in MSVC anyways...

Erik Rufelt
Erik Rufelt

Tried to use a C ogg/vorbis library to play music in a Windows Store app, but the VS 2013 compiler for ARM crashed every time I tried to build it (worked fine for x86). Didn't manage to find a workaround so switched audio formats.

ongamex92
ongamex92

You should try the intel's compiler :D

But yeah, something horribly wrong is happanening @ MS lately.

Oberon_Command
Oberon_Command

Here's some more:

- VS 2012 doesn't like you to declare or reference static variables in lambdas, even when the lambda is marked to capture everything by reference. I think VS 2015 fixed that.

- VS 2012 let you mark both a function's declaration and definition as "inline", while having them be in separate source files from where they're used. 2015 doesn't let you do this anymore, you get an "unresolved external." This is a bit of a pain when converting old code over.

SeanMiddleditch
SeanMiddleditch
Bah, those are easy. Causing an ICE (Internal Compiler Error) with Visual C++ or GCC or even Clang is something I usually do at least once a month.

Now, when you get to _miscompilation bugs_ that require you to dig through the generated assembly and find out why perfectly correct code is exhibiting incorrect behavior... that's when you start to have fun. smile.png

(Sounds like Juliean hit one of those!)

Visual C++ is definitely the crashiest of the compilers, but it's also got a huge amount of refactoring necessary to implement feature that its aging design just can't handle. Fun fact: Visual C++'s actual compiler doesn't even generate an AST internally, and also the C++ frontend used by the IDE for Intellisense is an entirely different C++ parser licensed from EDG. GCC and Clang are both very far away from being free of bugs, though; you're not a real C++ programmer if you haven't filed at least 10 ICE reports to their respective bug trackers. tongue.png
Sean Middleditch – Game Systems Engineer – Join my team!
l0calh05t
l0calh05t
1 did cause a miscompilation for me, not an ICE as the minimal example in the report. 2 was also a miscompilation.

And 1 was great fun to debug, because the miscompilation occurred in a dll built with mingw that is being used by an MSVC exe. Everything hidden behind a C interface of course.
Sik_the_hedgehog
Sik_the_hedgehog

That's nuts. I've seen one in about thirty years smile.png

I've already went far beyond that =/ (albeit honestly it's all pretty much assembler issues rather than compiler, although every so often I have IDE issues too)




Bah, those are easy. Causing an ICE (Internal Compiler Error) with Visual C++ or GCC or even Clang is something I usually do at least once a month.

You're dangerous.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Topic Locked

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

Sign in to reply to this topic.