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
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.
The typedef-namePosition_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.