public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/56085] New: Unsafe negation in C++03 pow(complex,int)
@ 2013-01-23 16:01 glisse at gcc dot gnu.org
  2013-01-23 16:46 ` [Bug libstdc++/56085] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-01-23 16:01 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085

             Bug #: 56085
           Summary: Unsafe negation in C++03 pow(complex,int)
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: glisse@gcc.gnu.org


template<typename _Tp>
    inline complex<_Tp>
    pow(const complex<_Tp>& __z, int __n)
    {
      return __n < 0
        ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -__n)
        : std::__complex_pow_unsigned(__z, __n);

If I understand correctly, -__n is undefined behavior for INT_MIN, and this
should use -(unsigned)__n instead to be safe. This is not just theoretical,
other projects had to do similar changes because gcc starting with 4.7 would
produce wrong code otherwise.


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

end of thread, other threads:[~2013-01-24 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-23 16:01 [Bug libstdc++/56085] New: Unsafe negation in C++03 pow(complex,int) glisse at gcc dot gnu.org
2013-01-23 16:46 ` [Bug libstdc++/56085] " rguenth at gcc dot gnu.org
2013-01-24 11:20 ` paolo.carlini at oracle dot com
2013-01-24 12:21 ` paolo at gcc dot gnu.org
2013-01-24 12:22 ` paolo.carlini at oracle dot com
2013-01-24 12:22 ` paolo at gcc dot gnu.org

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).