gansm / finalcut

A text-based widget toolkit
https://github.com/gansm/finalcut/wiki/First-steps#first-steps-with-the-final-cut-widget-toolkit
GNU Lesser General Public License v3.0
981 stars 52 forks source link

Compile error with clang++ -std=c++20 #122

Closed ghost closed 1 year ago

ghost commented 1 year ago

Describe the bug

Invocation of the clang++ compiler like clang++ -std=c++20 my_prog.cpp -o my_prog -lfinal gives me this error:

In file included from main.cpp:1:
In file included from /usr/include/final/final.h:29:
In file included from /usr/include/final/fapplication.h:68:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/vector:64:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/stl_vector.h:367:35: error: arithmetic on a pointer to an incomplete type 'finalcut::FListView::Header'
                      _M_impl._M_end_of_storage - _M_impl._M_start);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1/../../../../include/c++/12.2.1/bits/stl_vector.h:526:7: note: in instantiation of member function 'std::_Vector_base<finalcut::FListView::Header, std::allocator<finalcut::FListView::Header>>::~_Vector_base' requested here
      vector() = default;
      ^
/usr/include/final/widget/flistview.h:524:33: note: in defaulted default constructor for 'std::vector<finalcut::FListView::Header>' first required here
    HeaderItems           header{};
                                ^
/usr/include/final/widget/flistview.h:413:12: note: forward declaration of 'finalcut::FListView::Header'
    struct Header;  // forward declaration
           ^
1 error generated.

If I try to switch to the 17th standard, everything compiles without any errors or warnings.

I also noticed that if I compile with g++ (with std=c++20 and std=c++17), it also compiles normally. So it looks like this error only occurs with clang.

I have followed the build instructions described in the README.md.

How to reproduce the bug?

For example, compile one of the examples like clang++ -std=c++20 -O3 ui.cpp -o ui -lfinal

In which environment did the bug occur?

gansm commented 1 year ago

Thanks for the feedback. I did a little research on this issue and it seems to be the problem discussed on Stack Overflow:

https://stackoverflow.com/questions/75257501/confusion-or-clang-bug-about-incomplete-types-in-stdvector

I made a small change in my last commit (4480f38) that should allow your code to compile with clang++ 15 and -std=c++20.

ghost commented 1 year ago

Thanks for the response!

This fixed the issue. Thank you.