dimanche 1 mai 2016

Putting extra round brackets - code fails to compile

So, I have a function that returns a boolean

bool func_true()
{
    // do some stuff
    return true;
}

Now actual code call this like this

if (auto err = func_true())
{
    // some stuff
    std::cout << std::boolalpha << err << '\n';
}

All good till this point. If I put an extra round bracket around my call, compilation fails:

if ((auto err = func_true())) // doesn't compile!
{
    std::cout << std::boolalpha << err << '\n';
}

GCC Error: http://ift.tt/1W215qj

Is this a gcc bug, or I am doing something stupidly wrong?

Aucun commentaire:

Enregistrer un commentaire