Non-const reference bound to temporary, Visual Studio bug?

This is old extension to Visual Studio, the only reference I could find on the Microsoft site was this bug report: Temporary Objects Can be Bound to Non-Const References, which has the following example code:

struct A {};

A     f1();
void f2(A&);

int main()
{
    f2(f1()); // This line SHALL trigger an error, but it can be compiled without any     errors or warnings.
}

One of the responses notes:

There is a level 4 warning (level 4 warning are enabled if you pass /W4 to the compiler) for it

This blog post: Visual C++ is so Liberal which covers this extension notes that:

Using Disable Language Extensions (/Za) makes it an error:

Leave a Comment