From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12257 invoked by alias); 13 Jul 2014 17:55:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12219 invoked by uid 48); 13 Jul 2014 17:55:22 -0000 From: "kariya_mitsuru at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/61795] New: [C++11] return type of std::pow(std::complex, int) should be std::complex Date: Sun, 13 Jul 2014 17:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kariya_mitsuru at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00820.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61795 Bug ID: 61795 Summary: [C++11] return type of std::pow(std::complex, int) should be std::complex Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kariya_mitsuru at hotmail dot com With libstdc++, the return type of std::pow(std::complex, int) is std::complex. However, In C++11 mode, the return type of std::pow(std::complex, int) should be std::complex. According to C++11 standard 26.4.9[cmplx.over] paragraph 3, "if either argument has type complex, double, or an integer type, then both arguments are effectively cast to complex." The return type of std::pow(std::complex, std::complex) is std::complex, So I think that std::pow(std::complex, int) should be std::complex in C++11 mode. The sample code below can show whether the return type is std::complex. ================================================================================ #include #include #include int main() { std::cout << std::boolalpha << (typeid(std::pow(std::complex(1), 1)) == typeid(std::complex)) << std::endl; } ================================================================================ cf. http://melpon.org/wandbox/permlink/zW8TWZe9kKzKWqFq While in C++03 mode, the return type of std::pow(std::complex, int) should be std::complex, I think. Note that this problem does not occur in std::complex and std::complex because there is no difference between C++03 and C++11. See also: PR56106, PR57974