GCC's decltype(auto) doesn't conform to the standard?

一个人想着一个人 提交于 2019-12-04 04:24:58

Your reasoning is sound. And I think I see where GCC is tripping.

The wording for decltype(auto) says that auto is replaced with the expression in the initializer. Which according to GCC would imply your code is not equivalent to

decltype(a) b = a;

But rather it is equivalent to

decltype((a)) b = a;

But that is wrong. The initializer is "an unparenthesized id-expression", so the rules in [dcl.type.simple] for unparenthesized id-expressions should apply normally. The type of b needs to be deduced as int&&.


And as @Aconcagua was able to dig up, this is a known GCC bug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!