Skip to content
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 · 17 comments
Closed

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

fabianfrz opened this issue Jul 21, 2016 · 17 comments

Comments

@fabianfrz
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

junyer commented Jul 21, 2016

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

@junyer junyer changed the title It fails to compile using g++ It fails to compile using g++ 6.1.x Aug 1, 2016
@fabianfrz
Copy link
Author

Got an update but the problem does still appear.

Current version:
gcc (GCC) 6.1.1 20160802

@junyer
Copy link
Contributor

junyer commented Aug 11, 2016

Alas, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932 has not yet been fixed.

@tmsimont
Copy link

@junyer Where did you put this fix:

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

@junyer
Copy link
Contributor

junyer commented Sep 26, 2016

stefanv@86503cb is an example of the workaround.

@LordAro
Copy link

LordAro commented Sep 27, 2016

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

@junyer
Copy link
Contributor

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
Copy link

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
Copy link

jhseu commented Oct 16, 2016

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

@junyer
Copy link
Contributor

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
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
@ghost
Copy link

ghost commented Dec 22, 2016

Hasn't this been resolved in b94b7cd?

@junyer
Copy link
Contributor

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
Copy link
Contributor

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 as completed in d587bbc Dec 6, 2017
@stac47
Copy link

stac47 commented Feb 6, 2020

Hello,
For information, I got this problem with gcc 10 and C++20 support activated. I reported this here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93618.
I worked around the issue the same way you did in commit b94b7cd
Probably a temporary issue then.
Regards,

@junyer
Copy link
Contributor

junyer commented Feb 7, 2020

Thanks for letting me know! If the bug isn't fixed in time for the GCC 10.0 release, please feel free to file a new issue for RE2 to extend the workaround. (Otherwise, I will presumably take care of it when I add GCC 10.x to the Travis CI matrix.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants