ball_pit icon indicating copy to clipboard operation
ball_pit copied to clipboard

ICE on this module (not related to this repo)

Open dgcor opened this issue 3 years ago • 4 comments

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.

dgcor avatar Aug 17 '21 18:08 dgcor

Thank you for the report! Can you also open a report using Dev Comm if it is not too cumbersome?

I'll start looking into the issue right away!

cdacamar avatar Aug 17 '21 19:08 cdacamar

Thanks! I tried signing in using github but it had problems. I'd rather not create an account to open a report there.

dgcor avatar Aug 17 '21 19:08 dgcor

On a related subject, I ported my project to C++ modules. it's compiling on my machine using the latest version but the generated binary has errors when running.

https://github.com/dgcor/DGEngine-Modules

I created a repo with both the original and the modules versions of the same code, in case you want to try and see if it might be a compiler error or code error.

dgcor avatar Aug 18 '21 22:08 dgcor

I've updated my project to build using the latest CI image with VS2022.

https://github.com/dgcor/DGEngine-Modules

It's compiling both the classic and modules binaries. The classic opens the provided example, but the modules project doesn't.

I had to remove the sfeMovie folder from the project because, when using modules, vs is ignoring these:

    <ClCompile Include="src\sfeMovie\AudioStream.ixx">
      <ExcludedFromBuild Condition="'$(Configuration)'=='Release Static NoMovie'">true</ExcludedFromBuild>
      <ExcludedFromBuild Condition="'$(Configuration)'=='Release NoMovie'">true</ExcludedFromBuild>
      <ExcludedFromBuild Condition="'$(Configuration)'=='Debug NoMovie'">true</ExcludedFromBuild>
    </ClCompile>

dgcor avatar Oct 22 '21 22:10 dgcor