[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread bobogu at atlas dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #9 from bobogu at atlas dot cz --- (In reply to Jonathan Wakely from comment #8) > (In reply to bobogu from comment #7) > > All right, I'm sorry then... I just thought that as this is undocumented, it > > could lead to producing an unp

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #8 from Jonathan Wakely --- (In reply to bobogu from comment #7) > All right, I'm sorry then... I just thought that as this is undocumented, it > could lead to producing an unportable code. It could, except that you should get the sa

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread bobogu at atlas dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #7 from bobogu at atlas dot cz --- (In reply to Jonathan Wakely from comment #5) > (In reply to bobogu from comment #4) > All implementations define the assignment operator as defaulted, and so the > compiler makes it constexpr. > > I

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #6 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #5) > In fact the p0602R3 proposal you linked to is relevant, because it would > *require* implementations to define the operator as defaulted (in order to > be tri

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #5 from Jonathan Wakely --- (In reply to bobogu from comment #4) > I feel stupid, but I still don't understand how that can work in a constexpr > context when the current c++17 standard doesn't specify any constexpr > assignment opera

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread bobogu at atlas dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #4 from bobogu at atlas dot cz --- (In reply to Jonathan Wakely from comment #3) > (In reply to bobogu from comment #2) > When you assign an int to optional it is equivalent to constructing a > temporary optional and then assigning tha

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #3 from Jonathan Wakely --- (In reply to bobogu from comment #2) > Do I understand it correctly that this will get optimized into one statement > saying > > bar = std::optional(10); No, it's not an optimization. When you assign a

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread bobogu at atlas dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 --- Comment #2 from bobogu at atlas dot cz --- Do I understand it correctly that this will get optimized into one statement saying bar = std::optional(10); If so, is there something that could prevent such optimizations in order to check if th

[Bug c++/87016] std::optional::operator= in constexpr context

2018-08-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87016 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---