hubert.reinterpretcast added inline comments.

================
Comment at: clang/test/Sema/float128-ld-incompatibility.cpp:13
+long double ld{qf()}; // expected-error {{non-constant-expression cannot be 
narrowed from type '__float128' to 'long double' in initializer list}} 
expected-note {{insert an explicit cast to silence this issue}}
+__float128 q{ldf()}; // expected-no-error
 
----------------
hubert.reinterpretcast wrote:
> Should also test `__ibm128` cases.
The C++ committee has advised that this implicit conversion should be 
considered ill-formed (see other comment).

Note that the //allowed// implicit conversion from `__ibm128` to `long double` 
(and vice versa) is still a conversion, which means that overload resolution is 
still a problem:
```
void f(__ibm128);
void f(int);
void g(long double d) { return f(d); } // okay with GCC but not Clang; 
https://godbolt.org/z/fonsEbbY1
```


================
Comment at: clang/test/Sema/float128-ld-incompatibility.cpp:36-37
   q / ld; // expected-error {{invalid operands to binary expression 
('__float128' and 'long double')}}
-  ld = q; // expected-error {{assigning to 'long double' from incompatible 
type '__float128'}}
-  q = ld; // expected-error {{assigning to '__float128' from incompatible type 
'long double'}}
+  ld = q; // expected-no-error {{assigning to 'long double' from incompatible 
type '__float128'}}
+  q = ld; // expected-no-error {{assigning to '__float128' from incompatible 
type 'long double'}}
   q + b ? q : ld; // expected-error {{incompatible operand types ('__float128' 
and 'long double')}}
----------------
The C++ committee has advised that these are not okay as implicit conversions:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1467r7.html#implicit

Additional lines testing `static_cast` would be appropriate.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109751

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to