Skip to content

ICE on this module (not related to this repo) #2

Description

@dgcor

Hi,

I just want to report an ICE on vs 16.11 using modules.

Just create a new console application project and set /std:c++20

dependencies: rapidjson 1.1.0 - header only get it from vcpkg or copy the include folder to the project.

JsonParser.ixx

module;

#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING

#include "rapidjson/document.h";
#include "rapidjson/pointer.h";
#include "rapidjson/prettywriter.h";
#include "rapidjson/stringbuffer.h";
#include "rapidjson/writer.h";

export module json.parser;

export namespace rapidjson
{
	using rapidjson::CrtAllocator;
	using rapidjson::Document;
	using rapidjson::GenericMemberIterator;
	using rapidjson::GenericValue;
	using rapidjson::MemoryPoolAllocator;
	using rapidjson::Pointer;
	using rapidjson::PrettyWriter;
	using rapidjson::SizeType;
	using rapidjson::StringBuffer;
	using rapidjson::Value;
	using rapidjson::Writer;

	template <typename Encoding, typename Allocator>
	typename GenericValue<Encoding, Allocator>::ValueIterator begin(GenericValue<Encoding, Allocator>& v) { return v.Begin(); }
	template <typename Encoding, typename Allocator>
	typename GenericValue<Encoding, Allocator>::ConstValueIterator begin(const GenericValue<Encoding, Allocator>& v) { return v.Begin(); }

	template <typename Encoding, typename Allocator>
	typename GenericValue<Encoding, Allocator>::ValueIterator end(GenericValue<Encoding, Allocator>& v) { return v.End(); }
	template <typename Encoding, typename Allocator>
	typename GenericValue<Encoding, Allocator>::ConstValueIterator end(const GenericValue<Encoding, Allocator>& v) { return v.End(); }
}

main.cpp

import json.parser;

int main()
{
    rapidjson::Document doc;
}

error in document.h

    union Number {
#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN
        struct I {
            int i;
            char padding[4];
        }i;                                // ------------------------------ error here
        struct U {
            unsigned u;
            char padding2[4];
        }u;
#else
        struct I {
            char padding[4];
            int i;
        }i;
        struct U {
            char padding2[4];
            unsigned u;
        }u;
#endif
        int64_t i64;
        uint64_t u64;
        double d;
    };  // 8 bytes

Is there a limitation to unions with structs inside when using modules? I've had some other issues on this file:

https://github.com/dgcor/DGEngine.core/blob/master/src/SFML/Music2.h

when I tried to convert it to a module around the union. had to replace it with a variant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions