Title
const floating-point in constant expressions
Status
nad
Section
7.7 [expr.const]
Submitter
Ville Voutilainen

Created on 2014-01-04.00:00:00 last changed 108 months ago

Messages

Date: 2015-05-15.00:00:00

Rationale (May, 2015):

CWG felt that the current rules should not be changed and that programmers desiring floating point values to participate in constant expressions should use constexpr instead of const.

Date: 2022-11-20.07:54:16

Additional note, April, 2015:

EWG requested CWG to allow use of const floating-point variables in constant expressions.

Date: 2014-01-04.00:00:00

A const integer initialized with a constant can be used in constant expressions, but a const floating point variable initialized with a constant cannot. This was intentional, to be compatible with C++03 while encouraging the consistent use of constexpr. Some people have found this distinction to be surprising, however.

It was also observed that allowing const floating point variables as constant expressions would be an ABI-breaking change, since it would affect lambda capture.

One possibility might be to deprecate the use of const integral variables in constant expressions.

History
Date User Action Args
2015-05-25 00:00:00adminsetmessages: + msg5953
2015-05-25 00:00:00adminsetstatus: open -> nad
2015-04-13 00:00:00adminsetmessages: + msg5320
2015-04-13 00:00:00adminsetstatus: extension -> open
2014-03-03 00:00:00adminsetstatus: open -> extension
2014-01-04 00:00:00admincreate