https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69855
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-02-17
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Without the redundant parentheses we get another common mistake, trying to call
a default constructor for a local variable, but declaring a function:
struct mutex { };
mutex& get();
struct guard {
guard(mutex&) { }
};
void f()
{
guard get();
}
This is semantically identical to the previous version, but is also accepted
silently by G++.
Clang not only diagnoses the error, but has a fixit hint in case the intention
was to declare a local variable (which is useful for when the function
declaration doesn't conflict with an earlier one):
ww.cc:12:12: warning: empty parentheses interpreted as a function declaration
[-Wvexing-parse]
guard get();
^~
ww.cc:12:12: note: remove parentheses to declare a variable
guard get();
^~
ww.cc:12:9: error: functions that differ only in their return type cannot be
overloaded
guard get();
~~~~~ ^
ww.cc:4:8: note: previous declaration is here
mutex& get();
~~~~~~ ^
1 warning and 1 error generated.