[cfe-dev] [libcxx]: problem involving static const data members of class numeric_limits

Howard Hinnant hhinnant at apple.com
Thu Nov 29 07:44:44 PST 2012


On Nov 28, 2012, at 10:30 PM, ZhangXiongpang <zhangxiongpang at gmail.com> wrote:

> platform: linux, clang++3.2
> 
> testsuite:
> =======================================
> #include <limits>
> 
> void fun(const bool *&*) {}  // report error when the parameter type is
> reference type
> 
> int main() {
>    fun(std::numeric_limits<int>::is_specialized);
> }
> =======================================
> 
> *error: undefined reference to
> `std::__1::numeric_limits<int>::is_specialized'*
> 
> N3242 9.4.2.3 says:
> ---------------------------------------------------
> If a static data member is of const literal type, its declaration in the
> class definition can specify a brace-orequal-initializer in which every
> initializer-clause that is an assignment-expression is a constant
> expression.
> ...
> The member shall still be defined in a namespace scope if it is odrused
> (3.2) in the program and the namespace scope definition shall not contain an
> initializer.
> ---------------------------------------------------
> 
> I saw the static const data members (such as is_specialized, is_integer,
> etc.) of class numeric_limits declared with a initializer, but not defined
> out of class body. Is this libcxx's bug?

Yes, this looks like a libc++ bug to me.

Howard




More information about the cfe-dev mailing list