public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102157] New: floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression
@ 2021-09-01  7:35 xmh970252187 at gmail dot com
  2021-09-01 22:07 ` [Bug c++/102157] " pinskia at gcc dot gnu.org
  2021-09-02  3:11 ` xmh970252187 at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: xmh970252187 at gmail dot com @ 2021-09-01  7:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102157

            Bug ID: 102157
           Summary: floating-integral conversions is not permitted in the
                    user-defined conversion sequence in converted constant
                    expression
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

struct A{
    constexpr A(double const& rf){}
};
template<class T, T B>
struct C{};
int main() {
    C<A,0> b;
}

This code is accepted by GCC while rejected by Clang.  

[temp.arg.nontype] p2 
> A template-argument for a non-type template-parameter shall be a converted constant expression ([expr.const]) of the type of the template-parameter.  

>From a prvalue of type `int` to type `A`, the user-defined conversion sequence
will involve floating-integral conversions that are not permitted in
[expr.const] p10. GCC should reject this example.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/102157] floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression
  2021-09-01  7:35 [Bug c++/102157] New: floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression xmh970252187 at gmail dot com
@ 2021-09-01 22:07 ` pinskia at gcc dot gnu.org
  2021-09-02  3:11 ` xmh970252187 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-01 22:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102157

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-09-01

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There are two issues here really (both accepts invalid).
First is binding to a temp is invalid:
struct A{
    constexpr A(double const &rf){}
};
template<class T, T B>
struct C{};
int main() {
    C<A,0.> b;
}
----- CUT ----
Second is the conversion is also invalid:
struct A{
    constexpr A(double rf){}
};
template<class T, T B>
struct C{};
int main() {
    C<A,0> b;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/102157] floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression
  2021-09-01  7:35 [Bug c++/102157] New: floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression xmh970252187 at gmail dot com
  2021-09-01 22:07 ` [Bug c++/102157] " pinskia at gcc dot gnu.org
@ 2021-09-02  3:11 ` xmh970252187 at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: xmh970252187 at gmail dot com @ 2021-09-02  3:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102157

--- Comment #2 from jim x <xmh970252187 at gmail dot com> ---
bind the temporary is permitted here to me. Since the template parameter is not
a reference type, there is no restriction on whether a temporary object is
generated in the implicit conversion.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-02  3:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01  7:35 [Bug c++/102157] New: floating-integral conversions is not permitted in the user-defined conversion sequence in converted constant expression xmh970252187 at gmail dot com
2021-09-01 22:07 ` [Bug c++/102157] " pinskia at gcc dot gnu.org
2021-09-02  3:11 ` xmh970252187 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).