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

FixedStringTest build fails on Ubuntu 20.04 due to errors with constant expressions #1444

Open
emmenlau opened this issue Sep 11, 2020 · 12 comments

Comments

@emmenlau
Copy link

I'm trying to build folly latest master (rev f5744f5) on Ubuntu 20.04 x86_64 with 9.3.0. The build fails with the following error:

FAILED: CMakeFiles/fixed_string_test.dir/folly/test/FixedStringTest.cpp.o 
/data/user/Tools/lib/ccache/c++ -DBOOST_ALL_NO_LIB -DFMT_LOCALE -DFOLLY_XLOG_STRIP_PREFIXES=\"/home/user/folly:/data/user/Debug/folly\" -DGFLAGS_IS_A_DLL=0 -DGOOGLE_GLOG_DLL_DECL="" -DGOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS="" -D_GNU_SOURCE -D_REENTRANT -I/home/user/folly -I. -isystem /data/user/Debug/include -ggdb3 -fno-omit-frame-pointer -O1 -m64 -march=skylake -DDEBUG -g -g -Wall -Wextra -fPIE -g -std=gnu++1z -finput-charset=UTF-8 -fsigned-char -Wall -Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare -Wno-unused -Wunused-label -Wunused-result -Wshadow-compatible-local -Wno-noexcept-type -faligned-new -fopenmp -pthread -std=gnu++17 -MD -MT CMakeFiles/fixed_string_test.dir/folly/test/FixedStringTest.cpp.o -MF CMakeFiles/fixed_string_test.dir/folly/test/FixedStringTest.cpp.o.d -o CMakeFiles/fixed_string_test.dir/folly/test/FixedStringTest.cpp.o -c /home/user/folly/folly/test/FixedStringTest.cpp
In file included from /home/user/folly/folly/Range.h:26,
                 from /home/user/folly/folly/FixedString.h:33,
                 from /home/user/folly/folly/test/FixedStringTest.cpp:20:
/home/user/folly/folly/portability/Constexpr.h: In member function ‘virtual void FixedStringEraseTest_CEraseTest_Test::TestBody()’:
/home/user/folly/folly/test/FixedStringTest.cpp:420:42:   in ‘constexpr’ expansion of ‘x.folly::BasicFixedString<char, 26>::cerase(x.folly::BasicFixedString<char, 26>::size(), ((std::size_t)folly::detail::fixedstring::FixedStringBase_<>::npos))’
/home/user/folly/folly/FixedString.h:1476:19:   in ‘constexpr’ expansion of ‘((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::creplace<1>(pos, folly::detail::fixedstring::checkOverflowOrNpos(count, (((long unsigned int)((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::size_) - folly::detail::fixedstring::checkOverflow(pos, ((std::size_t)((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::size_)))), A{})’
/home/user/folly/folly/FixedString.h:1898:59:   in ‘constexpr’ expansion of ‘((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::creplace<1>(this_pos, this_count, (* & that), 0, (1 - 1))’
/home/user/folly/folly/FixedString.h:1938:49:   in ‘constexpr’ expansion of ‘folly::detail::fixedstring::checkNullTerminated<char, 1>((* & that))’
/home/user/folly/folly/FixedString.h:100:61:   in ‘constexpr’ expansion of ‘folly::constexpr_strlen<char>(((const char*)a))’
/home/user/folly/folly/portability/Constexpr.h:103:43:   in ‘constexpr’ expansion of ‘folly::detail::constexpr_strlen_internal<char>(s, 0)’
/home/user/folly/folly/portability/Constexpr.h:48:29: error: ‘strlen(((const char*)(&<anonymous>)))’ is not a constant expression
   48 |   return FOLLY_DETAIL_STRLEN(s);
      |                             ^
/home/user/folly/folly/test/FixedStringTest.cpp:421:21: error: non-constant condition for static assertion
  421 |   static_assert(26u == tmp0.size(), "");
      |                 ~~~~^~~~~~~~~~~~~~
/home/user/folly/folly/test/FixedStringTest.cpp:422:19: error: non-constant condition for static assertion
  422 |   static_assert(y == tmp0, "");
      |                 ~~^~~~~~~
/home/user/folly/folly/test/FixedStringTest.cpp:424:21: error: non-constant condition for static assertion
  424 |   static_assert(24u == tmp1.size(), "");
      |                 ~~~~^~~~~~~~~~~~~~
/home/user/folly/folly/test/FixedStringTest.cpp:425:44: error: non-constant condition for static assertion
  425 |   static_assert("abcdefghijklmnopqrstuvwx" == tmp1, "");
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/user/folly/folly/test/FixedStringTest.cpp:427:20: error: non-constant condition for static assertion
  427 |   static_assert(2u == tmp2.size(), "");
      |                 ~~~^~~~~~~~~~~~~~
/home/user/folly/folly/test/FixedStringTest.cpp:428:22: error: non-constant condition for static assertion
  428 |   static_assert("ax" == tmp2, "");
      |                 ~~~~~^~~~~~~
@emmenlau
Copy link
Author

Anyone? I can't believe I'm the only one facing this issue?

@emmenlau
Copy link
Author

Build still fails on latest release v2020.09.28.00

@emmenlau
Copy link
Author

I think the commit that breaks Ubuntu 18.04 for me is 08e2614 , @ericniebler does that make sense?

@boringuy
Copy link

Got the same error on CentOS7 with devtoolset-7

@bolunfeng
Copy link

@emmenlau I have the same question on ubuntu 20.04,Have you solved this problem?

@emmenlau
Copy link
Author

No, I think this library is just not well maintained. There was no response from core team in 6 weeks, for a broken build :-( :-(

@ericniebler
Copy link
Contributor

I apologize for the lack of response. I haven't succeeded in reproducing this, despite trying. I've punched the relevant bits of FixedString into godbolt and tried every gcc compiler version I can, and I haven't gotten it to fail yet. https://godbolt.org/z/5eK6oq. I must be doing something wrong.

@emmenlau
Copy link
Author

emmenlau commented Nov 4, 2020

Hi @ericniebler thanks for considering this issue! Admittedly I did not think it might be hard to reproduce.

I do compile a number of folly-dependencies from scratch so there is a small chance that this adds to the problem. However I don't think FixedStringTest.cpp makes use of many of these.

Furthermore I define a number of CXXFLAGS in the environment: -DDEBUG -ggdb3 -fno-omit-frame-pointer -O0 -m64 -march=skylake.

Do you think this may be related? If non of this helps, we can just leave the issue hanging. Sadly the folly build fails for me so regularly on the one or other platform that I anyways will not be able to use it any time soon :-(

@ghost
Copy link

ghost commented Feb 28, 2021

I meet the same problem, do you fix this in the end?

@aytey
Copy link

aytey commented Mar 7, 2021

tl;dr: if you want to see a reproducer for this problem, go here: https://godbolt.org/z/rcr8W7

I'm experiencing this exact issue with OpenSUSE Tumbleweed (20210223) using GCC 10.2.1. Given how "easy" it is to reproduce this for me on Tumbleweed, I created a reproducer here:

This reproducer merges the following files:

  • folly/CPortability.h
  • folly/portability/Constexpr.h
  • folly/FixedString.h
  • folly/test/FixedStringTest.cpp

into one file and gets the following error:

pre_generated_1444.cpp: In function ‘void FixedStringEraseTestCEraseTest()’:
pre_generated_1444.cpp:3765:42:   in ‘constexpr’ expansion of ‘x.folly::BasicFixedString<char, 26>::cerase(x.folly::BasicFixedString<char, 26>::size(), ((std::size_t)folly::detail::fixedstring::FixedStringBase_<>::npos))’
pre_generated_1444.cpp:1790:20:   in ‘constexpr’ expansion of ‘((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::creplace<1>(pos, folly::detail::fixedstring::checkOverflowOrNpos(count, (((long unsigned int)((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::size_) - folly::detail::fixedstring::checkOverflow(pos, ((std::size_t)((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::size_)))), A{'\000'})’
pre_generated_1444.cpp:2212:20:   in ‘constexpr’ expansion of ‘((const folly::BasicFixedString<char, 26>*)this)->folly::BasicFixedString<char, 26>::creplace<1>(this_pos, this_count, (* & that), 0, (1 - 1))’
pre_generated_1444.cpp:2252:49:   in ‘constexpr’ expansion of ‘folly::detail::fixedstring::checkNullTerminated<char, 1>((* & that))’
pre_generated_1444.cpp:493:61:   in ‘constexpr’ expansion of ‘folly::constexpr_strlen<char>(((const char*)a))
pre_generated_1444.cpp:382:43:   in ‘constexpr’ expansion of ‘folly::detail::constexpr_strlen_internal<char>(s, 0)
pre_generated_1444.cpp:329:29: error: ‘__builtin_strlen(((const char*)(&<anonymous>)))’ is not a constant expression
  329 |   return FOLLY_DETAIL_STRLEN(s);
      |                             ^
pre_generated_1444.cpp:3766:21: error: non-constant condition for static assertion
 3766 |   static_assert(26u == tmp0.size(), "");
      |                 ~~~~^~~~~~~~~~~~~~
pre_generated_1444.cpp:3767:19: error: non-constant condition for static assertion
 3767 |   static_assert(y == tmp0, "");
      |                 ~~^~~~~~~
pre_generated_1444.cpp:3769:21: error: non-constant condition for static assertion
 3769 |   static_assert(24u == tmp1.size(), "");
      |                 ~~~~^~~~~~~~~~~~~~
pre_generated_1444.cpp:3770:44: error: non-constant condition for static assertion
 3770 |   static_assert("abcdefghijklmnopqrstuvwx" == tmp1, "");
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
pre_generated_1444.cpp:3772:20: error: non-constant condition for static assertion
 3772 |   static_assert(2u == tmp2.size(), "");
      |                 ~~~^~~~~~~~~~~~~~
pre_generated_1444.cpp:3773:22: error: non-constant condition for static assertion
 3773 |   static_assert("ax" == tmp2, "");
      |                 ~~~~~^~~~~~~

If you don't want to run my shell script to re-generate this file, I've uploaded a pre-prepared a version here: https://github.com/andrewvaughanj/folly_1444/blob/master/pre_generated_1444.cpp.

Everything else in the test-file compiles apart from the content of TEST(FixedStringEraseTest, CEraseTest).

@cloudren2017
Copy link

image

I add a 'u' and fix this problem.

@vaavaav
Copy link

vaavaav commented Nov 22, 2024

From what I could deduce, Folly needs at least g++-11.
However, the default for Ubuntu 20.04 and 18.04 is g++-9 and g++-7, respectively, thus failing to compile.

My suggestion is to add this restriction to the CMakeLists.txt like so:

if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
    message(FATAL_ERROR "GCC version must be 11 or higher")
endif()

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

7 participants