Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2039. Constant conversions tobool

Section:14.5  [except.spec]    Status:CD4    Submitter:Richard Smith    Date:2014-11-09

[Adopted at the February, 2016 meeting.]

According to 14.5 [except.spec] paragraph 1,

In anoexcept-specification,theconstant-expression, if supplied, shall be aconstant expression (7.7 [expr.const]) that iscontextually converted to bool (7.3 [conv]).

This allows the expression to have any type that can be convertedtobool, which is too lenient; it should instead say somethinglike “a converted constant expression of typebool(7.7 [expr.const]).” This would include theconversion tobool in the determination of whether theexpression is constant or not and would also disallow narrowingconversions.

A similar consideration applies tostatic_assert(9.1 [dcl.pre] paragraph 6), which should probably berecast to something like, “an expression that is a constantexpression (7.7 [expr.const]) after contextual conversiontobool (7.3 [conv]).”

Proposed resolution (September, 2015):

  1. Change 7.7 [expr.const] paragraph 4 as follows:

  2. ...binds directly. [Note: such expressions may be used in newexpressions (7.6.2.8 [expr.new]), as case expressions(8.5.3 [stmt.switch]), as enumerator initializers if the underlyingtype is fixed (9.8.1 [dcl.enum]), as array bounds(9.3.4.5 [dcl.array]), and as non-type template arguments(13.4 [temp.arg]). —end note]Acontextuallyconverted constant expression of typebool is an expression,contextually converted tobool (7.3 [conv]),where the converted expression is a constant expression and the conversionsequence contains only the conversions above.
  3. Change 9.1 [dcl.pre] paragraph 6 as follows:

  4. In astatic_assert-declaration,theconstant-expression shall be acontextually convertedconstant expressionof typebool(7.7 [expr.const])that can be contextually convertedtobool (7.3 [conv]). If the value of theexpression when so converted istrue...
  5. Change 14.5 [except.spec] paragraph 1 as follows:

  6. In anoexcept-specification, theconstant-expression, ifsupplied, shall be acontextually converted constant expressionof typebool (7.7 [expr.const])that iscontextually converted tobool (7.3 [conv]). A( token thatfollowsnoexcept...



[8]ページ先頭

©2009-2026 Movatter.jp