c++c++builderc++builder-xe7

"E2188 Expression syntax error" when passing default-constructed object to function


class MBool  
{
   protected:
      bool  mData;  
   public:
      MBool() : mData(false)          {}
      MBool(bool  Data)               { mData = Data; }
};

void myFunc ( const MBool& rBool )
{
}

bool test()
{
   myFunc( MBool() );
   myFunc( ( MBool() ) );  // <-- Error E2188 Expression syntax
   myFunc( MBool( false ) );
   myFunc( ( MBool( false ) ) ); 
}

Can someone please help explain the above error? It occurs using Embarcadero's XE7. The same code compiles fine using Visual Studio. The problem on XE7, as demonstrated, only occurs in the second line of the test method, all other cases compile fine.

EDIT Sorry, I pasted the wrong constructor in my example, it's fixed now. When surrounded by parentheses, the constructor with the boolean parameter compiles, but the parameterless constructor won't compile.


Solution

  • This is a bug in bcc32.exe . The code works correctly in bcc64.

    Here is a MCVE:

    void f(int) {}
    
    int main()
    {
        f((int()));    // E2188 Expression syntax
    }
    

    As a workaround, take out the extra pair of parentheses.