Discussion:
[std-discussion] constexpr & volatile
Tadeus Prastowo
2018-07-19 15:15:07 UTC
Permalink
Hi!

The following program is ill-formed or not for its use of volatile
constexpr variables?

template<typename T, T v> struct X {};
int main() {
static constexpr volatile int a = 3;
constexpr volatile int b = 2;
return (sizeof(X<decltype(a), a>) + sizeof(X<decltype(b), b>));
}

I think it is ill-formed based on
http://eel.is/c++draft/temp.arg.nontype (#1 and #2) and
http://eel.is/c++draft/expr.const#2.7. However...

GCC 8.1 compiles fine (https://godbolt.org/g/o8UPiJ), MSVC 19 2017
compiles fine too (https://godbolt.org/g/rvyMtX), but not clang-6.0
(https://godbolt.org/g/HUQXUM) and not GCC 5.5
(https://godbolt.org/g/MQRCdE).

That's why I ask about this matter in this list. Thank you.

--
Best regards,
Tadeus
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Tadeus Prastowo
2018-07-30 11:25:33 UTC
Permalink
Any opinion on the following matter I posted about two weeks ago?

On Thu, Jul 19, 2018 at 5:15 PM, Tadeus Prastowo
Post by Tadeus Prastowo
Hi!
The following program is ill-formed or not for its use of volatile
constexpr variables?
template<typename T, T v> struct X {};
int main() {
static constexpr volatile int a = 3;
constexpr volatile int b = 2;
return (sizeof(X<decltype(a), a>) + sizeof(X<decltype(b), b>));
}
I think it is ill-formed based on
http://eel.is/c++draft/temp.arg.nontype (#1 and #2) and
http://eel.is/c++draft/expr.const#2.7. However...
GCC 8.1 compiles fine (https://godbolt.org/g/o8UPiJ), MSVC 19 2017
compiles fine too (https://godbolt.org/g/rvyMtX), but not clang-6.0
(https://godbolt.org/g/HUQXUM) and not GCC 5.5
(https://godbolt.org/g/MQRCdE).
That's why I ask about this matter in this list. Thank you.
--
Best regards,
Tadeus
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-07-30 13:54:28 UTC
Permalink
I agree with you that clang is correct and the code is ill-formed.
Post by Tadeus Prastowo
Any opinion on the following matter I posted about two weeks ago?
On Thu, Jul 19, 2018 at 5:15 PM, Tadeus Prastowo
Post by Tadeus Prastowo
Hi!
The following program is ill-formed or not for its use of volatile
constexpr variables?
template<typename T, T v> struct X {};
int main() {
static constexpr volatile int a = 3;
constexpr volatile int b = 2;
return (sizeof(X<decltype(a), a>) + sizeof(X<decltype(b), b>));
}
I think it is ill-formed based on
http://eel.is/c++draft/temp.arg.nontype (#1 and #2) and
http://eel.is/c++draft/expr.const#2.7. However...
GCC 8.1 compiles fine (https://godbolt.org/g/o8UPiJ), MSVC 19 2017
compiles fine too (https://godbolt.org/g/rvyMtX), but not clang-6.0
(https://godbolt.org/g/HUQXUM) and not GCC 5.5
(https://godbolt.org/g/MQRCdE).
That's why I ask about this matter in this list. Thank you.
--
Best regards,
Tadeus
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Tadeus Prastowo
2018-07-30 16:51:58 UTC
Permalink
Thank you. GCC has acknowledged the bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86608 as a regression.
Post by Nicolas Lesser
I agree with you that clang is correct and the code is ill-formed.
Post by Tadeus Prastowo
Any opinion on the following matter I posted about two weeks ago?
On Thu, Jul 19, 2018 at 5:15 PM, Tadeus Prastowo
Post by Tadeus Prastowo
Hi!
The following program is ill-formed or not for its use of volatile
constexpr variables?
template<typename T, T v> struct X {};
int main() {
static constexpr volatile int a = 3;
constexpr volatile int b = 2;
return (sizeof(X<decltype(a), a>) + sizeof(X<decltype(b), b>));
}
I think it is ill-formed based on
http://eel.is/c++draft/temp.arg.nontype (#1 and #2) and
http://eel.is/c++draft/expr.const#2.7. However...
GCC 8.1 compiles fine (https://godbolt.org/g/o8UPiJ), MSVC 19 2017
compiles fine too (https://godbolt.org/g/rvyMtX), but not clang-6.0
(https://godbolt.org/g/HUQXUM) and not GCC 5.5
(https://godbolt.org/g/MQRCdE).
That's why I ask about this matter in this list. Thank you.
--
Best regards,
Tadeus
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Loading...