New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It fails to compile using g++ 6.1.x #102

Closed
fabianfrz opened this Issue Jul 21, 2016 · 15 comments

Comments

Projects
None yet
6 participants
@fabianfrz

fabianfrz commented Jul 21, 2016

g++ -c -o obj/dbg/re2/dfa.o  -std=c++11 -pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I.   -O3 -g re2/dfa.cc
re2/dfa.cc: In Konstruktor »re2::DFA::State::State()«:
re2/dfa.cc:95:10: Fehler: unbekannte Feldgröße in »delete«
   struct State {
          ^~~~~
re2/dfa.cc: In Elementfunktion »re2::DFA::State* re2::DFA::CachedState(int*, int, re2::uint)«:
re2/dfa.cc:703:9: Anmerkung: erzeugte Methode »re2::DFA::State::State()« zuerst hier erfordert 
   State state;
         ^~~~~
make: *** [Makefile:190: obj/dbg/re2/dfa.o] Fehler 1

When I forced it to use clang++ with "make CXX=clang++ test" it worked.

Versions:
clang version 3.8.0 (tags/RELEASE_380/final)
g++ (GCC) 6.1.1 20160707

Translation of the error message to english (if that helps you):
re2/dfa.cc:95:10: Error: unknown array size in »delete«

@junyer

This comment has been minimized.

Member

junyer commented Jul 21, 2016

Ouch! :(

As per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932, this seems to be due to a regression in GCC 6.1. For now, you should be able to work around the problem by changing the flexible array member to a zero-sized array member as follows:

    std::atomic<State*> next_[0];    // Outgoing arrows from State,

I will let you know what the GCC folks say.

@junyer

This comment has been minimized.

Member

junyer commented Jul 21, 2016

Martin Sebor said that it's actually https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71147, which was fixed a couple of months ago. However, the 20160707 snapshot should have included that fix, so I will have to follow up.

@junyer

This comment has been minimized.

Member

junyer commented Jul 21, 2016

It's both of those bugs, apparently. :)

@junyer junyer changed the title from It fails to compile using g++ to It fails to compile using g++ 6.1.x Aug 1, 2016

@fabianfrz

This comment has been minimized.

fabianfrz commented Aug 10, 2016

Got an update but the problem does still appear.

Current version:
gcc (GCC) 6.1.1 20160802

@junyer

This comment has been minimized.

Member

junyer commented Aug 11, 2016

@tmsimont

This comment has been minimized.

tmsimont commented Sep 25, 2016

@junyer Where did you put this fix:

std::atomic<State*> next_[0];    // Outgoing arrows from State,
@junyer

This comment has been minimized.

Member

junyer commented Sep 26, 2016

stefanv@86503cb is an example of the workaround.

@LordAro

This comment has been minimized.

LordAro commented Sep 27, 2016

Out of interest, is there any reason you couldn't make next_ a vector?

@junyer

This comment has been minimized.

Member

junyer commented Sep 28, 2016

next_ used to be a pointer, but I changed it in commit c78a2a5 for performance reasons. Changing it to a std::vector<> would introduce a similar pointer chase with a similar performance hit.

@jhseu

This comment has been minimized.

Member

jhseu commented Oct 16, 2016

It looks like Ubuntu 16.10 includes gcc 6.2, which still has this bug. TensorFlow depends on re2 at the moment, so it also breaks the TensorFlow build in the latest version of Ubuntu. Could we submit a workaround for now?

@jhseu

This comment has been minimized.

Member

jhseu commented Oct 16, 2016

Sent a proposed fix at #122 that avoids both flexible array members and undefined behavior.

@junyer

This comment has been minimized.

Member

junyer commented Oct 17, 2016

It's unfortunate that this bug hasn't been fixed yet, but I'd prefer not to throw the baby out with the bathwater, so I'm going to commit the workaround that I've described previously.

gopherbot pushed a commit that referenced this issue Oct 17, 2016

Work around the GCC bug affecting flexible array members.
For #102.

Change-Id: I0e4270f7e492a59b0ee43c523378b7b9d941f38a
Reviewed-on: https://code-review.googlesource.com/8492
Reviewed-by: Paul Wankadia <junyer@google.com>

thomaskrause added a commit to thomaskrause/graphANNIS that referenced this issue Oct 28, 2016

@tuncer

This comment has been minimized.

tuncer commented Dec 22, 2016

Hasn't this been resolved in b94b7cd?

@junyer

This comment has been minimized.

Member

junyer commented Dec 22, 2016

I'm keeping this open until the GCC folks have fixed the regression because I'll have to tweak the workaround if, for example, the regression still exists in 7.0.

@junyer

This comment has been minimized.

Member

junyer commented Dec 6, 2017

No one has reported breakage with GCC 7.x and our build matrix on Travis CI is clean. I'm going to adjust the comment on the workaround and then close this bug.

@junyer junyer closed this in d587bbc Dec 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment