[Bug c++/87384] Likely syntax error not reported as such
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Sep 21 19:34:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87384
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jan Engelhardt from comment #0)
> $ cat x.cpp
> void (*f)(const char *, int &&...);
> void g(const char *, int &&a, int &&b) {}
> int main() { f = g; return 0; }
>
> OBSERVED:
> $ g++-8 -c x.cpp
> x.cpp: In function ‘int main()’:
> x.cpp:3:18: error: invalid conversion from ‘void (*)(const char*, int&&,
> int&&)’ to ‘void (*)(const char*, int&&, ...)’ [-fpermissive]
> int main() { f = g; return 0; }
>
> EXPECTED:
> That "int &&..." be reported as a syntax error of some kind. An argument
> pack is normally only viable with a template, isn't it.
That's not a template parameter pack, it's a printf-style variadic function.
The comma before the ... is optional, so your code means exactly the same as:
void (*f)(const char *, int &&, ...);
void g(const char *, int &&a, int &&b) {}
int main() { f = g; return 0; }
And indeed that's exactly what the error message tells you.
More information about the Gcc-bugs
mailing list