profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/alexey-romanov/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

alexey-romanov/cgcourse2019 0

Computer Graphics 2019 Fall Term

alexey-romanov/pfr 0

std::tuple like methods for user defined types without any macro or boilerplate code

alexey-romanov/PML30Summer2021 0

PML 30 Summer practice samples

issue closedboostorg/pfr

fields_count compilation error for structures with sizeof() >= 256 compiled via msvc <= 19.20, c++17

Trying to use boost::pfr::for_each_field on structures with sizeof() >= 256 on msvc compiler version <= 19.20 (e.g. all the versions of Visual Studio 2017) gives the following error:

boost/pfr/detail/fields_count.hpp(101): fatal error C1202: recursive type or function dependency context too complex

Structure field count doesn't matter just the size does.

Samples:

  1. Compilation error, structure size is exact 256 bytes Link to this sample on Godbolt: https://godbolt.org/z/3TdzddMM7
#include "boost/pfr.hpp"

#pragma pack(push, 1)
struct Foo {
    long long a0;
    long long a1;
    long long a2;
    long long a3;
    long long a4;
    long long a5;
    long long a6;
    long long a7;
    long long a8;
    long long a9;
    long long a10;
    long long a11;
    long long a12;
    long long a13;
    long long a14;
    long long a15;
    long long a16;
    long long a17;
    long long a18;
    long long a19;
    long long a20;
    long long a21;
    long long a22;
    long long a23;
    long long a24;
    long long a25;
    long long a26;
    long long a27;
    long long a28;
    long long a29;
    long long a30;
    long long a31;
};
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}
  1. No compilation error, structure size is 255 bytes
#include "boost/pfr.hpp"

#pragma pack(push, 1)
struct Foo {
    long long a0;
    long long a1;
    long long a2;
    long long a3;
    long long a4;
    long long a5;
    long long a6;
    long long a7;
    long long a8;
    long long a9;
    long long a10;
    long long a11;
    long long a12;
    long long a13;
    long long a14;
    long long a15;
    long long a16;
    long long a17;
    long long a18;
    long long a19;
    long long a20;
    long long a21;
    long long a22;
    long long a23;
    long long a24;
    long long a25;
    long long a26;
    long long a27;
    long long a28;
    long long a29;
    long long a30;
    int i0;
    char c0;
    char c1;
    char c2;
};
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}
  1. Compilation error, less fields structure size is > 256 (280 to be precise)
#include "boost/pfr.hpp"
#include <string>

#pragma pack(push, 1)
struct Foo {
    std::string s0;
    std::string s1;
    std::string s2;
    std::string s3;
    std::string s4;
    std::string s5;
    std::string s6;
    std::string s7;
    std::string s8;
    std::string s9;
   };
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}

closed time in 2 months

alexey-romanov

pull request commentboostorg/pfr

workaround for msvc compilers <= 1920

@apolukhin changeset updated, please re-review

alexey-romanov

comment created time in 2 months

Pull request review commentboostorg/pfr

workaround for msvc compilers <= 1920

 constexpr std::size_t fields_count() noexcept { //    ); //#endif +#if defined(_MSC_VER) && (_MSC_VER <= 1920)+    // Workaround for msvc compilers. Versions <= 1920 have a limit of max 1024 elements in template parameter pack+    constexpr std::size_t max_fields_count = boost::static_unsigned_min<sizeof(type) * CHAR_BIT, 1024>::value;

ok

alexey-romanov

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentboostorg/pfr

workaround for msvc compilers <= 1920

 #include <boost/pfr/detail/size_t_.hpp> #include <boost/pfr/detail/unsafe_declval.hpp> +#include <boost/integer/static_min_max.hpp>

ACK, done.

alexey-romanov

comment created time in 2 months

PullRequestReviewEvent

push eventalexey-romanov/pfr

Aleksei Romanov

commit sha d1e7e87a31e2b794783f23270c63219cf33be8f1

workaround for msvc compilers <= 1920

view details

push time in 2 months

issue commentboostorg/pfr

fields_count compilation error for structures with sizeof() >= 256 compiled via msvc <= 19.20, c++17

At the core the error comes from enable_if_constructible_helper<T>(detail::make_index_sequence<N>()). It appears that for VS2017 family compilers there is a limit of max 1024 element in a template parameter pack. Regarding the workaround, what about taking the min(sizeof(T)*BIT_COUNT, 1024) for VS2017? This would work for majority of the cases and give errors otherwise. Here is the pull request https://github.com/boostorg/pfr/pull/88

alexey-romanov

comment created time in 2 months

PR opened boostorg/pfr

woraround for msvc compilers <= 1920

msvc compilers <= 1920 (VS2017 family compilers and below) have a limit on max 1024 elements in template parameter pack. Limit max_fields_count for this particular case.

+8 -0

0 comment

1 changed file

pr created time in 2 months

push eventalexey-romanov/pfr

Aleksei Romanov

commit sha d0db98559932b6e3afb10e732b74958550a0bc37

woraround for msvc compilers <= 1920

view details

push time in 2 months

fork alexey-romanov/pfr

std::tuple like methods for user defined types without any macro or boilerplate code

https://boost.org/libs/pfr

fork in 2 months

issue openedboostorg/pfr

fields_count compilation error for structures with sizeof() >= 256 compiled via msvc <= 19.20

Trying to use boost::pfr::for_each_field on structures with sizeof() >= 256 on msvc compiler version <= 19.20 (e.g. all the versions of Visual Studio 2017) gives the following error:

boost/pfr/detail/fields_count.hpp(101): fatal error C1202: recursive type or function dependency context too complex

Structure field count doesn't matter just the size does.

Samples:

  1. Compilation error, structure size is exact 256 bytes Link to this sample on Godbolt: https://godbolt.org/z/3TdzddMM7
#include "boost/pfr.hpp"

#pragma pack(push, 1)
struct Foo {
    long long a0;
    long long a1;
    long long a2;
    long long a3;
    long long a4;
    long long a5;
    long long a6;
    long long a7;
    long long a8;
    long long a9;
    long long a10;
    long long a11;
    long long a12;
    long long a13;
    long long a14;
    long long a15;
    long long a16;
    long long a17;
    long long a18;
    long long a19;
    long long a20;
    long long a21;
    long long a22;
    long long a23;
    long long a24;
    long long a25;
    long long a26;
    long long a27;
    long long a28;
    long long a29;
    long long a30;
    long long a31;
};
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}
  1. No compilation error, structure size is 255 bytes
#include "boost/pfr.hpp"

#pragma pack(push, 1)
struct Foo {
    long long a0;
    long long a1;
    long long a2;
    long long a3;
    long long a4;
    long long a5;
    long long a6;
    long long a7;
    long long a8;
    long long a9;
    long long a10;
    long long a11;
    long long a12;
    long long a13;
    long long a14;
    long long a15;
    long long a16;
    long long a17;
    long long a18;
    long long a19;
    long long a20;
    long long a21;
    long long a22;
    long long a23;
    long long a24;
    long long a25;
    long long a26;
    long long a27;
    long long a28;
    long long a29;
    long long a30;
    int i0;
    char c0;
    char c1;
    char c2;
};
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}
  1. Compilation error, less fields structure size is > 256 (280 to be precise)
#include "boost/pfr.hpp"
#include <string>

#pragma pack(push, 1)
struct Foo {
    std::string s0;
    std::string s1;
    std::string s2;
    std::string s3;
    std::string s4;
    std::string s5;
    std::string s6;
    std::string s7;
    std::string s8;
    std::string s9;
   };
#pragma pack(pop)

void test()
{
    Foo foo;
    boost::pfr::for_each_field(foo, [](auto& field) { });
}

created time in 2 months