Giter Site home page Giter Site logo

Comments (9)

arthaud avatar arthaud commented on August 18, 2024

It looks like this will be fixed in libc++: https://bugs.llvm.org/show_bug.cgi?id=40230

from container.

igaztanaga avatar igaztanaga commented on August 18, 2024

Thanks for the report. This nasty pair class was used to portably support all compilers (including C++03 compilers, where std::pair had no move semantics or placement constructors.) One workaround is to embed an internal std::pair inside the dtl::pair class to guarantee excatly the same memory layout.

The second step would be to use the native std::pair on compilers withou full C++11 support.

I'll try the first workaround in the following days and inform about progress in this bug.

from container.

igaztanaga avatar igaztanaga commented on August 18, 2024

The first workaround is not possible because pair exposes "first" and "second" as public members. We can try to reproduce the padding in libcpp with the following patch. Could please test it, as I haven't been able to set up the virtual machine yet?
boost_container_libcpp.txt

from container.

arthaud avatar arthaud commented on August 18, 2024

Thanks for the patch. Unfortunately I'm getting the following error:

$ c++ test.cpp -I/tmp/boost/include
In file included from test.cpp:3:
In file included from /tmp/boost/include/container/include/boost/container/flat_map.hpp:29:
In file included from /tmp/boost/include/container/include/boost/container/detail/flat_tree.hpp:29:
/tmp/boost/include/container/include/boost/container/detail/pair.hpp:211:67: error: too many arguments provided to function-like macro invocation
   : pair_padding<T1, T2, offsetof(std::pair<T1 BOOST_MOVE_I T2>, first) >
                                                                  ^
/usr/include/sys/cdefs.h:476:9: note: macro '__offsetof' defined here
#define __offsetof(type, field)  __builtin_offsetof(type, field)
        ^
In file included from test.cpp:3:
In file included from /tmp/boost/include/container/include/boost/container/flat_map.hpp:29:
In file included from /tmp/boost/include/container/include/boost/container/detail/flat_tree.hpp:29:
/tmp/boost/include/container/include/boost/container/detail/pair.hpp:211:27: error: use of undeclared identifier '__offsetof'
   : pair_padding<T1, T2, offsetof(std::pair<T1 BOOST_MOVE_I T2>, first) >
                          ^
/usr/include/stddef.h:75:31: note: expanded from macro 'offsetof'
#define offsetof(type, field)   __offsetof(type, field)
                                ^
In file included from test.cpp:3:
In file included from /tmp/boost/include/container/include/boost/container/flat_map.hpp:29:
In file included from /tmp/boost/include/container/include/boost/container/detail/flat_tree.hpp:29:
/tmp/boost/include/container/include/boost/container/detail/pair.hpp:213:1: error: expected class name
{
^
3 errors generated.

Regarding the patch, I would like to suggest to check for _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead of _LIBCPP_VERSION. This will avoid possible regressions on most systems and save compile time.

from container.

arthaud avatar arthaud commented on August 18, 2024

It compiles with -std=c++11 but the bug is still there, I'm trying to investigate this.

EDIT: It was an error on my side. It still doesn't compile with -std=c++11

EDIT 2: It looks like a common macro problem, where the comma in std::pair< T1, T2 > is treated as an argument separator for the macro offset_of. This is probably why you tried to use BOOST_MOVE_I but it didn't work.

from container.

igaztanaga avatar igaztanaga commented on August 18, 2024

I've reproduced the problem in Linux using clang -stdlib=libc++ and defining "_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR".

New patch attached, the patch
boost_container_pair_libcpp_patch.txt
compiles in C++03 and C++2a modes.

from container.

arthaud avatar arthaud commented on August 18, 2024

I confirm that the patch fixes the issue, thank you.

from container.

igaztanaga avatar igaztanaga commented on August 18, 2024

Many thanks for the report and help solving the issue. Fixed in commit:

2b5197a

from container.

igaztanaga avatar igaztanaga commented on August 18, 2024

There was a typo in the committed patch, corrected with commit:

8078925

from container.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.