事实上,正如在评论中所讨论的,这是GCC中的一个bug,但是我想我应该对这个bug的本质有一些额外的见解。在海湾合作委员会
NEWS file
-
__FUNCTION__
和
__PRETTY_FUNCTION__
printf (__FUNCTION__ ": foo")
必须重写为
printf ("%s: foo", __FUNCTION__)
但是
__函数__
constexpr.c
:
case DECL_EXPR:
{
tree decl = DECL_EXPR_DECL (body);
if (TREE_CODE (decl) == USING_DECL
/* Accept __func__, __FUNCTION__, and __PRETTY_FUNCTION__. */
|| DECL_ARTIFICIAL (decl))
return NULL_TREE;
return error_mark_node;
}
如果它真的是一个变量,我们会期望它通过与以下相同的测试用例:
constexpr const char* s2 = "TEST";
constexpr const char* s3 = s2;
test_template<ce_strlen("TEST")> c;
test_template<ce_strlen(s2)> d;
test_template<ce_strlen(s3)> e;