billyquith/ponder

fatal error C1001 when using arrays with Visual Studio 2015

AntAgna opened this issue · 6 comments

If I take the code of this file : https://github.com/billyquith/ponder/blob/master/test/ponder/arrayproperty.cpp

And I modify bool bools[2]; to bool bools[3];
And try to build using Visual Studio 2015 in x86 Debug

I get this error :

1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1443): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 255)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information

Is there a way to use arrays larger than 2 apart from using std::array ?

Which update of VS2015 are you using? Lots of bugs were fixed in updates 2 & 3, including one I encountered with similar error messages. I recommend Update 3.

I don't think the problem is the array size. I think it is is some error in VS2015. Perhaps something to do with checking the array bounds?, e.g. https://github.com/billyquith/ponder/blob/master/test/ponder/arrayproperty.cpp#L171

If I make that change and compile using Xcode clang (3.8?) it compiles and fails, as expected:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pondertest is a Catch v1.5.6 host application.
Run with -? for options

-------------------------------------------------------------------------------
Property arrays can be read
-------------------------------------------------------------------------------
ponder/test/ponder/arrayproperty.cpp:167
...............................................................................

ponder/test/ponder/arrayproperty.cpp:171: FAILED:
  REQUIRE_THROWS_AS( bools->get(object, 2) )
because no exception was thrown where one was expected:

===============================================================================
test cases:   56 |   55 passed | 1 failed
assertions: 1544 | 1543 passed | 1 failed

Program ended with exit code: 1

I think my visual studio is fully up to date : VS2015 Update 3 14.0.25431.01, with compiler version 19.00.24215.1

The problem is a bug in the compiler. I have reported the problem to Microsoft

Here is a simplified version of the code that also fails to compile : main.zip

Bummer. Maybe try VS2017? I believe a lot of work has been done on C++ and it supports many C++17 features. Hopefully that would mean other bugs have been fixed.

Thanks for the sample. I'll just paste it here for reference.

#include <ponder/classget.hpp>
#include <ponder/errors.hpp>
#include <ponder/arrayproperty.hpp>
#include <ponder/class.hpp>
#include <ponder/classbuilder.hpp>

struct ExampleStruct
{
	static void declare();	// For introspection

	int Array1[10];
};
PONDER_AUTO_TYPE(ExampleStruct, &ExampleStruct::declare)	// Will automatically call declare()

inline void ExampleStruct::declare()
{
	// Declare structure members
	ponder::Class::declare< ExampleStruct >("ExampleStruct")
		.property("Array1", &ExampleStruct::Array1)
		;
}

int main()
{
	const ponder::Class& Class = ponder::classByType<ExampleStruct>();
	return 0;
}

I have tested with Visual Studio 2017 and the problem is also there.