13

I am getting some strange behaviour with a C++11 std::array. When I try to compile with std::array<std::tuple<int, float>, 6> myTuples; as a member variable, I get these errors:

mingw32\4.7.2\include\c++\array:-1: In instantiation of 'struct std::array<std::tuple<int, float>, 6u>':
mingw32\4.7.2\include\c++\array:77: error: 'std::array<_Tp, _Nm>::_M_instance' has incomplete type

I'm not sure if any of this changes anything but the class it is in is a template class derived from another template class. The template parameter is an unsigned int an determines the size of a protected std::array in the base class, which I reference in the derived class using Base<param>::m_array;. The derived class has various glm::vec3/dmat4/quat types, and uses OpenGL fixed function glBegin(GL_QUADS); stuff. I'm using SDL-1.2.15 to create an OpenGL context. I think most of that was irrelevant, but maybe not. I could paste code, but everything is interconnected, so it can only be compiled as a whole (which distributed between sources is around a thousand or so lines).

However, when I include this same line in this ideone example, in very similar circumstances, it compiles perfectly fine. I checked that it wasn't just my compiler (MinGW g++ version 4.7.2) by compiling the same on my compiler with command line g++ -Wall -std=c++11

Does anyone know why I might get these errors? I had some problems before with the compiler crashing while parsing std::array assignment (using array = {{a,b,c}}; for a default parameter), but this time its a compiler error not crash.

steve9164
  • 426
  • 2
  • 11
  • 22
  • 15
    Have you done `#include `? – dunc123 Aug 09 '13 at 11:05
  • 3
    I can reproduce a similar error if you forget to include ``. Actually, the same exact error with g++4.7 `/usr/include/c++/4.7/array:77:43: error: ‘std::array<_Tp, _Nm>::_M_instance’ has incomplete type` – Jesse Good Aug 09 '13 at 11:07
  • Post an [SSCCE](http://sscce.org/). – juanchopanza Aug 09 '13 at 11:10
  • "*I checked that it wasn't just my compiler [...] by compiling the same on my compiler*" Using the same compiler *twice* is *not* how you check for compiler errors. – Nicol Bolas Aug 09 '13 at 11:13
  • @NicolBolas What I meant was that I thought maybe it was just my compiler that had issues, so I simplified the problem and then compiled on ideone's compiler (which I think is GCC 4.8). This worked so I then suspected that my compiler might have a bug. Testing with my original compiler revealed that the error on the single line was not a compiler bug. – steve9164 Aug 10 '13 at 02:52
  • @JesseGood Yep, that's the problem. Well diagnosed. Could you post that as an answer? – steve9164 Aug 10 '13 at 02:59

1 Answers1

15

As per requested, you forgot to include <tuple> which is why the compiler complained of an incomplete type.

Jesse Good
  • 50,901
  • 14
  • 124
  • 166