[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #14 from Jonathan Wakely --- (In reply to pj from comment #9) > The only modification described by the paper (relevant to this case) is the > requirement that `T_i x[] = {std::forward(t)};` is well formed, That code gives you a diagn

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #13 from Jonathan Wakely --- It does. The array initialization uses a braced-init-list, which is the context in which narrowing conversions are diagnosed. Please take this to stackoverflow if you're unclear what the change entails. T

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread pj at patrickjohnston dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #12 from pj at patrickjohnston dot org --- Intentions aside, the concrete change given at the bottom of the paper doesn't seem to reflect the non-narrowing conversion constraint

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread mclow.lists at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #11 from Marshall Clow --- With wrapping: > Proposed Resolution: > This paper proposes to constrain the variant converting constructor and the > converting assignment operator to prevent narrowing conversions > and conversions to

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread mclow.lists at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 Marshall Clow changed: What|Removed |Added CC||mclow.lists at gmail dot com --- Comment

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread pj at patrickjohnston dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #9 from pj at patrickjohnston dot org --- I'm sorry to belabour this, but I don't see how narrowing conversions even has anything to do with p0608. The only modification described by the paper (relevant to this case) is the requiremen

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #8 from Jonathan Wakely --- Because the narrowing conversion happens inside the Double(int) constructor. The constrain on the variant(T&&) constructor only checks if a Double can be constructed from an int without narrowing. Which it

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread pj at patrickjohnston dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #7 from pj at patrickjohnston dot org --- Yeah but the `variant{600}` doesn't fail to compile due to this narrowing conversion

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #6 from Jonathan Wakely --- Because the Double(int) constructor takes an int, and so passing it an int is not a narrowing conversion. Try defining that constructor differently and you'll get a warning about a narrowing conversion ins

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-13 Thread pj at patrickjohnston dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #5 from pj at patrickjohnston dot org --- So then why does `std::variant{600}` work just fine? (Where `Double` is defined by `struct Double { double x; Double(int){} };`)

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 Jonathan Wakely changed: What|Removed |Added Status|NEW |RESOLVED Resolution|---

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 Jonathan Wakely changed: What|Removed |Added Keywords||rejects-valid Status|WAITI

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-11 Thread pj at patrickjohnston dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 --- Comment #2 from pj at patrickjohnston dot org --- Initialising a `variant` from an `int` should not be an error due to p0608. Compared to before, p0608 only requires that `double x[] = {600};` is well formed. See https://wandbox.org/permlink/I

[Bug libstdc++/92057] variant converting constructor fails for primitives

2019-10-10 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed|