[libcxx-commits] [PATCH] D133535: [libc++] Suppress -Wctad-maybe-unsupported on types w/o deduction guides

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 29 23:19:33 PDT 2022


Mordante added a comment.

In D133535#3825383 <https://reviews.llvm.org/D133535#3825383>, @ldionne wrote:

> In particular, I think the code `std::variant v{3}` is extremely suspicious (why on earth would you create a variant
> that always contains an int -- this must usually be a mistake). So instead, I'm tempted to let the warning warn when
> CTAD is used with variant.

I think there are valid cases.

  #ifdef FOO
  std::variant<int, double> v{foo(...);};
  #else
  std::variant<int, double> v{42};
  #endif

But since it's only a warning users can just compile without the flag and be happy. So I don't think we need to support this feature. But I feel the test should be fixed instead of removed.

I like the format contexts also to keep using CTAD, I don't feel writing the template types there makes the code easier to understand.



================
Comment at: libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.bool.pass.cpp:47
 
-  std::basic_format_context format_ctx =
+  FormatCtxT format_ctx =
       test_format_context_create<decltype(out), CharT>(out, std::make_format_args<FormatCtxT>(arg));
----------------
nice catch.


================
Comment at: libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/ctor.pass.cpp:43
   ASSERT_NOEXCEPT(
-      std::basic_format_parse_context{std::basic_string_view<CharT>{}});
+      std::basic_format_parse_context<CharT>{std::basic_string_view<CharT>{}});
   ASSERT_NOEXCEPT(
----------------
Here too I prefer CTAD to work.


================
Comment at: libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp:258
-    std::variant<int, double> v1(3);
-    std::variant v2 = v1;
-    (void)v2;
----------------
This line is what is tested, this is no longer ill-formed. So I would prefer to keep this test and instead adjust the construction.

I wonder how many libc++ users use this construct. Does it only warn when the types are convertible or always?
For example will this also generate a diagnostic?
```
std::variant<int, std::string_view> v1(3);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133535/new/

https://reviews.llvm.org/D133535



More information about the libcxx-commits mailing list