Use of address-constant pointers in constant expressions
7.7 [expr.const]
Daniel Kr├╝gler

Created on 2010-09-02.00:00:00 last changed 96 months ago


Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

Change 7.7 [expr.const] paragraph 2 bullet 19 as follows:

  • a relational (7.6.9 [expr.rel]) or equality (7.6.10 [expr.eq]) operator where at least one of the operands is a pointer the result is unspecified;

Date: 2010-09-02.00:00:00

It's not clear whether the current rules for constant expressions allow indirect calls of constexpr functions and constexpr member functions; for example,

    constexpr bool is_negative(int x) { return x < 0; }
    constexpr bool check(int x, bool (*p)(int)) { return p(x); }
    static_assert(check(-2, is_negative), "Error");

If this is to be permitted, there does not seem to be a reason to prohibit equality comparison of pointers to functions or pointers to objects of static storage duration -- these can be tracked as is already done for non-type template parameters.

Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3319
2011-04-10 00:00:00adminsetstatus: ready -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3052
2010-11-29 00:00:00adminsetstatus: open -> ready
2010-09-02 00:00:00admincreate