public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kariya_mitsuru at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/61795] [C++11] return type of std::pow(std::complex<float>, int) should be std::complex<double>
Date: Mon, 14 Jul 2014 03:41:00 -0000	[thread overview]
Message-ID: <bug-61795-4-hjmUeaabtD@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61795-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Mitsuru Kariya <kariya_mitsuru at hotmail dot com> ---
I think that this behaviour is caused by r201253 (for PR57974, Comment 11).
DR844 was fixed by r136694 but reverted by r201253.

diff r135878 r136694
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/complex?r1=135878&r2=136694

diff r199924 r201253
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/complex?r1=199924&r2=201253


Moreover, I think that I mistook.

> Note that this problem does not occur in std::complex<double> and
> std::complex<long double> because there is no difference between
> C++03 and C++11.

This is not true.

In C++03, the 2nd argument of std::pow can cause implicit conversions.
(Because it is the trivial int type.)
However, I believe that it should cause no implicit conversion in C++11.
(I think so from C++11 standard text quoted above.)

Therefore, I think that the sample code below should be compiled successfully
in C++03 mode but should cause compilation error in C++11 mode.

===================================================================
#include <complex>

struct S {
  operator int() { return 1; }
};

int main()
{
  std::complex<double> d = std::pow(std::complex<double>(0), S());
}
===================================================================


  parent reply	other threads:[~2014-07-14  3:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 17:55 [Bug libstdc++/61795] New: " kariya_mitsuru at hotmail dot com
2014-07-13 18:29 ` [Bug libstdc++/61795] " daniel.kruegler at googlemail dot com
2014-07-14  3:41 ` kariya_mitsuru at hotmail dot com [this message]
2015-04-09 15:43 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61795-4-hjmUeaabtD@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).