Is most vexing parse a formally defined concept

is the concept of “most vexing parse” formally defined by the C++ standard.

No. There is no concept of “most vexing parse” defined in the C++ standard. The standard does define the grammar from which the ambiguities arise, and it defines the rule that resolves the ambiguities, but it doesn’t name the ambiguities.

According to Wikipedia: “The term “most vexing parse” was first used by Scott Meyers in his 2001 book Effective STL.”. The example in the book is:

Item 6. Be alert for C++’s most vexing parse.

ifstream dataFile("ints.dat");
list<int> data(istream_iterator<int>(dataFile), // warning! this doesn't do
               istream_iterator<int>());        // what you think it does

The way I would describe “MVP” is that there is an intention to declare a variable, with passed argument(s), but you end up actually writing a function declaration and the intended arguments turn out as parameter declarators.


does the statement ArrTest ar(); uses most vexing parse.

The book explicitly mentions this ambiguity as well:

If you’ve been programming in C++ for a while, you’ve almost certainly encountered another manifestation of this rule. How many times have you seen this mistake?

class Widget {...}; // assume Widget has a default constructor
Widget w();         //'uh oh...

Given that the author who came up with the name for the ambiguity considers this as another manifestation – as opposed to the same manifestation – of a language rule, I would say that the example in question is not the “MVP”. It’s another, similar, and in my opinion less vexing ambiguity.

Leave a Comment