Strange error with using type aliases, compiles fine in clang but not MinGW

I have code that compiles just fine in clang++ 3.3, but when I use nuwen MinGW 4.8.1 to compile this it gives a strange error that (as with last time) I cannot isolate or reproduce.

This is the code segment in question:
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        class Board
        {
        public:
            using BoardSize_t = config::BoardConfig::BoardSize_t;
            using Position_t = config::BoardConfig::Position_t;


            using Suit = config::BoardConfig::SuitClass_t;

            class Piece
            {
            public:
                using PosList_t = std::set<Position_t>;
                using Position_t = Board::Position_t; //error in MinGW 
The full source can be found here: https://github.com/LB--/ChessPlusPlus/blob/lb-refactor/src/board/Board.hpp#L34

This is the error message:
In file included from C:\Users\Nicholas\Desktop\GitHub\ChessPlusPlus\src\gfx/Gra
phics.hpp:7:0,
                 from C:\Users\Nicholas\Desktop\GitHub\ChessPlusPlus\src\AppStat
eGame.hpp:6,
                 from C:\Users\Nicholas\Desktop\GitHub\ChessPlusPlus\src\Applica
tion.hpp:5,
                 from C:\Users\Nicholas\Desktop\GitHub\ChessPlusPlus\src\Applica
tion.cpp:1:
C:/Users/Nicholas/Desktop/GitHub/ChessPlusPlus/src/board/Board.hpp:34:53: error:
 declaration of 'using Position_t = using Position_t = using Position_t = class
chesspp::util::Position<unsigned char>' [-fpermissive]
                 using Position_t = Board::Position_t;
                                                     ^
C:/Users/Nicholas/Desktop/GitHub/ChessPlusPlus/src/board/Board.hpp:25:63: error:
 changes meaning of 'Position_t' from 'using Position_t = using Position_t = cla
ss chesspp::util::Position<unsigned char>' [-fpermissive]
             using Position_t = config::BoardConfig::Position_t;
                                                               ^
I have tried to reproduce the error to isolate it but nothing I do can reproduce the error, and I honestly have no idea why this is a problem. The thing that confuses me is that this works fine in clang, but MinGW complains here.

This is really frustrating me - I don't want to simply comment out line 34 and replace references to the alias.
Last edited on
swap lines 33 and 34.

1
2
3
                //using PosList_t = std::set<Position_t>;
                using Position_t = Board::Position_t; 
                using PosList_t = std::set<Position_t>;
Wow, I can't believe I missed that. Why didn't clang complain then?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
template<typename T>
struct container
{
};

struct Outer
{
	using type_t = int;
	struct Inner
	{
		using container_t = container<type_t>;
		using type_t = Outer::type_t;
	};
};

int main()
{
}
clang happily accepts this code, whereas MinGW rejects it.

EDIT: http://stackoverflow.com/q/19231959/1959975
Last edited on
The typedef-name Position_t in the outer scope (class Board) was already visible, and the later type alias declaration in the class did not change its meaning.

It appears to me that the clang behaviour is correct, since a typedef-name is just a synonym for a type. But I may well be wrong.
I got this answer on Stack Overflow:
http://stackoverflow.com/a/19232203/1959975
So apparently both MinGW and clang are correct, which is a bit silly. I wonder how many other rules can be violated without a requirement for a diagnostic.
Yeah. Thanks LB.
Topic archived. No new replies allowed.