notcurses icon indicating copy to clipboard operation
notcurses copied to clipboard

3.0.8: build fails with latest gcc

Open kloczek opened this issue 1 year ago • 6 comments

Looks like recent gcc changes in gcc used in fedora rawhide are causing fails

[ 68%] Building CXX object CMakeFiles/notcurses-tester.dir/src/tests/bitmap.cpp.o
/usr/bin/g++ -D_DEFAULT_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/include -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8 -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/x86_64-redhat-linux-gnu/include -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -DNDEBUG -fvisibility=hidden -Wformat -Werror=format-security -Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2 -fno-signed-zeros -fno-trapping-math -fassociative-math -fno-math-errno -freciprocal-math -funsafe-math-optimizations -fexceptions -fstrict-aliasing -std=c++17 -MD -MT CMakeFiles/notcurses-tester.dir/src/tests/bitmap.cpp.o -MF CMakeFiles/notcurses-tester.dir/src/tests/bitmap.cpp.o.d -o CMakeFiles/notcurses-tester.dir/src/tests/bitmap.cpp.o -c /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/bitmap.cpp
In file included from /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/main.h:9,
                 from /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/bitmap.cpp:1:
/usr/include/doctest/doctest.h: In instantiation of ‘static void doctest::detail::filldata<T*>::fill(std::ostream*, const T*) [with T = int(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int); std::ostream = std::basic_ostream<char>]’:
/usr/include/doctest/doctest.h:1025:26:   required from ‘void doctest::detail::filloss(std::ostream*, const T&) [with T = int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int); std::ostream = std::basic_ostream<char>]’
/usr/include/doctest/doctest.h:1038:16:   required from ‘doctest::String doctest::detail::toStream(const T&) [with T = int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int)]’
/usr/include/doctest/doctest.h:1046:28:   required from ‘static doctest::String doctest::detail::StringMakerBase<true>::convert(const T&) [with T = int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int)]’
/usr/include/doctest/doctest.h:1079:35:   required from ‘doctest::String doctest::toString(const T&) [with T = int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int); typename detail::types::enable_if<(! detail::types::is_enum<T>::value), bool>::type <anonymous> = true]’
/usr/include/doctest/doctest.h:1476:32:   required from ‘doctest::detail::Expression_lhs<L>::operator doctest::detail::Result() [with L = int (*&)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int)]’
/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/bitmap.cpp:20:7:   required from here
/usr/include/doctest/doctest.h:1166:49: error: invalid conversion from ‘int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int)’ to ‘const void*’ [-fpermissive]
 1166 |             filldata<const void*>::fill(stream, in);
      |                                                 ^~
      |                                                 |
      |                                                 int (*)(const tinfo*, const ncpile*, sprixel*, fbuf*, int, int)
/usr/include/doctest/doctest.h:1160:60: note:   initializing argument 2 of ‘static void doctest::detail::filldata<const void*>::fill(std::ostream*, const void*)’
 1160 |         static void fill(std::ostream* stream, const void* in);
      |                                                ~~~~~~~~~~~~^~
make[2]: *** [CMakeFiles/notcurses-tester.dir/build.make:135: CMakeFiles/notcurses-tester.dir/src/tests/bitmap.cpp.o] Error 1
[ 68%] Building CXX object CMakeFiles/notcurses-tester.dir/src/tests/tabbed.cpp.o
/usr/bin/g++ -D_DEFAULT_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/include -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8 -I/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/x86_64-redhat-linux-gnu/include -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -DNDEBUG -fvisibility=hidden -Wformat -Werror=format-security -Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2 -fno-signed-zeros -fno-trapping-math -fassociative-math -fno-math-errno -freciprocal-math -funsafe-math-optimizations -fexceptions -fstrict-aliasing -std=c++17 -MD -MT CMakeFiles/notcurses-tester.dir/src/tests/tabbed.cpp.o -MF CMakeFiles/notcurses-tester.dir/src/tests/tabbed.cpp.o.d -o CMakeFiles/notcurses-tester.dir/src/tests/tabbed.cpp.o -c /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/tabbed.cpp
In file included from /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/main.h:9,
                 from /home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/tabbed.cpp:1:
/usr/include/doctest/doctest.h: In instantiation of ‘static void doctest::detail::filldata<T*>::fill(std::ostream*, const T*) [with T = void(nctab*, ncplane*, void*); std::ostream = std::basic_ostream<char>]’:
/usr/include/doctest/doctest.h:1025:26:   required from ‘void doctest::detail::filloss(std::ostream*, const T&) [with T = void (*)(nctab*, ncplane*, void*); std::ostream = std::basic_ostream<char>]’
/usr/include/doctest/doctest.h:1038:16:   required from ‘doctest::String doctest::detail::toStream(const T&) [with T = void (*)(nctab*, ncplane*, void*)]’
/usr/include/doctest/doctest.h:1046:28:   required from ‘static doctest::String doctest::detail::StringMakerBase<true>::convert(const T&) [with T = void (*)(nctab*, ncplane*, void*)]’
/usr/include/doctest/doctest.h:1079:35:   required from ‘doctest::String doctest::toString(const T&) [with T = void (*)(nctab*, ncplane*, void*); typename detail::types::enable_if<(! detail::types::is_enum<T>::value), bool>::type <anonymous> = true]’
/usr/include/doctest/doctest.h:1318:49:   required from ‘doctest::String doctest::detail::stringifyBinaryExpr(const L&, const char*, const R&) [with L = void(nctab*, ncplane*, void*); R = void (*)(nctab*, ncplane*, void*)]’
/usr/include/doctest/doctest.h:1485:9:   required from ‘decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) doctest::detail::Expression_lhs<L>::operator==(R&&) [with R = void (*)(nctab*, ncplane*, void*); L = void (&)(nctab*, ncplane*, void*); decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) = doctest::detail::Result]’
/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/src/tests/tabbed.cpp:398:5:   required from here
/usr/include/doctest/doctest.h:1166:49: error: invalid conversion from ‘void (*)(nctab*, ncplane*, void*)’ to ‘const void*’ [-fpermissive]
 1166 |             filldata<const void*>::fill(stream, in);
      |                                                 ^~
      |                                                 |
      |                                                 void (*)(nctab*, ncplane*, void*)
/usr/include/doctest/doctest.h:1160:60: note:   initializing argument 2 of ‘static void doctest::detail::filldata<const void*>::fill(std::ostream*, const void*)’
 1160 |         static void fill(std::ostream* stream, const void* in);
      |                                                ~~~~~~~~~~~~^~
make[2]: *** [CMakeFiles/notcurses-tester.dir/build.make:625: CMakeFiles/notcurses-tester.dir/src/tests/tabbed.cpp.o] Error 1
make[2]: Target 'CMakeFiles/notcurses-tester.dir/build' not remade because of errors.
make[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/notcurses-3.0.8/x86_64-redhat-linux-gnu'
make[1]: *** [CMakeFiles/Makefile2:2518: CMakeFiles/notcurses-tester.dir/all] Error 2
make  -f CMakeFiles/notcurses.3.man.dir/build.make CMakeFiles/notcurses.3.man.dir/depend

kloczek avatar Aug 10 '22 10:08 kloczek

egads! it looks like this has to do with doctest. i'll get on it asap.

dankamongmen avatar Aug 10 '22 13:08 dankamongmen

hrmmm, not running into this on debian unstable. what environment and g++ version?

dankamongmen avatar Aug 10 '22 13:08 dankamongmen

I'm using gcc from Fedora rawhide gcc-12.1.1-3.fc37.x86_64 I also wtote https://lists.fedoraproject.org/archives/list/[email protected]/thread/NW75YZ3VIXGO2TOPC33AS47VDJDVQKIE/

kloczek avatar Aug 10 '22 16:08 kloczek

thanks; i'll bring up my fedora VM later today and see what's what.

dankamongmen avatar Aug 10 '22 16:08 dankamongmen

Any update? 🤔

kloczek avatar Aug 24 '22 08:08 kloczek

same error on arch, gcc 12.2.0

building worked after commenting out these lines: ./src/tests/bitmap.cpp:17-21

     CHECK(0 < nc_->tcache.cellpxy); 
     CHECK(0 < nc_->tcache.cellpxx); 
     if(!nc_->tcache.pixel_draw_late){ 
       CHECK(nc_->tcache.pixel_draw); 
     }

./src/tests/tabbed.cpp:398

    CHECK(tabbedcb == nctab_cb(t1));

msftceo avatar Sep 12 '22 07:09 msftceo

i don't want to say that this is a bug ion doctest, but i'm not sure exactly what's up. i fixed one problem. i hope to have this resolved today. thanks for your patience!

dankamongmen avatar Sep 27 '22 18:09 dankamongmen

so all the failure points involve function pointers, and we break in this part of doctest:

/usr/include/doctest/doctest.h:1046:28:   required from ‘static doctest::String doctest::detail::StringMakerBase<true>::convert(const T&) [with T = void (*)(nctab*, ncplane*, void*)]’
/usr/include/doctest/doctest.h:1079:35:   required from ‘doctest::String doctest::toString(const T&) [with T = void (*)(nctab*, ncplane*, void*); typename detail::types::enable_if<(! detail::types::is_enum<T>::value), bool>::type <anonymous> = true]’
/usr/include/doctest/doctest.h:1318:49:   required from ‘doctest::String doctest::detail::stringifyBinaryExpr(const L&, const char*, const R&) [with L = void(nctab*, ncplane*, void*); R = void (*)(nctab*, ncplane*, void*)]’

so it's trying to turn the expression into a string to show when it fails, and it's running into some problem:

/usr/include/doctest/doctest.h:1485:9:   required from ‘decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) doctest::detail::Expression_lhs<L>::operator==(R&&) [with R = void (*)(nctab*, ncplane*, void*); L = void (&)(nctab*, ncplane*, void*); decltype (((void)((declval<L>() == declval<R>())), (doctest::detail::Result)(<brace-enclosed initializer list>()))) = doctest::detail::Result]’

@Saalvage, would you mind taking a quick look at this? it started breaking with doctest 2.4.9. it might very well be my misuse of the library, but maybe you'll know quickly.

dankamongmen avatar Sep 27 '22 18:09 dankamongmen

if i manually cast things to const void*, they compile, e.g.:

[schwarzgerat](0) $ git diff
diff --git src/tests/bitmap.cpp src/tests/bitmap.cpp
index 9f56ea788..d0f39d80e 100644
--- src/tests/bitmap.cpp
+++ src/tests/bitmap.cpp
@@ -17,7 +17,7 @@ TEST_CASE("Bitmaps") {
     CHECK(0 < nc_->tcache.cellpxy);
     CHECK(0 < nc_->tcache.cellpxx);
     if(!nc_->tcache.pixel_draw_late){
-      CHECK(nc_->tcache.pixel_draw);
+      CHECK((const void*)nc_->tcache.pixel_draw);
     }
   }
 
diff --git src/tests/tabbed.cpp src/tests/tabbed.cpp
index 272b09e2d..9adc7ae7d 100644
--- src/tests/tabbed.cpp
+++ src/tests/tabbed.cpp
@@ -395,7 +395,7 @@ TEST_CASE("Tabbed") {
     CHECK(0 == strcmp(sep, nctabbed_separator(nt)));
     auto t1 = nctabbed_add(nt, nullptr, nullptr, tabbedcb, "tab1", nullptr);
     nctab_set_cb(t1, tabbedcb);
-    CHECK(tabbedcb == nctab_cb(t1));
+    CHECK((const void*)(tabbedcb) == (const void*)nctab_cb(t1));
     nctab_set_userptr(t1, (void*) sep);
     CHECK((void*) sep == nctab_userptr(t1));
     const char* tname = "tab name";
[schwarzgerat](0) $ 

dankamongmen avatar Sep 27 '22 18:09 dankamongmen

i think this might be https://github.com/doctest/doctest/issues/686, and if so, we're just gonna need to wait for 2.4.10, and mark that as a dep, ugh.

dankamongmen avatar Sep 27 '22 18:09 dankamongmen

Yep, seems like an instance of that issue. Sorry for the inconvenience, looking to get 2.4.10 out of the door next week!

Saalvage avatar Oct 01 '22 17:10 Saalvage

Yep, seems like an instance of that issue. Sorry for the inconvenience, looking to get 2.4.10 out of the door next week!

these things happen. thanks for the confirmation. i'll go ahead and exclude 2.4.9 in the CMake config.

dankamongmen avatar Oct 02 '22 00:10 dankamongmen

i'm going to go ahead and put in a workaround to get things compiling again.

dankamongmen avatar Oct 04 '22 08:10 dankamongmen

alright, imma cut a 3.0.9 to get us past this bullshit

dankamongmen avatar Oct 04 '22 09:10 dankamongmen