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
* [Bug libstdc++/56085] Unsafe negation in C++03 pow(complex,int)
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 ` rguenth at gcc dot gnu.org
2013-01-24 11:20 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-01-23 16:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-01-23
Ever Confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-23 16:46:02 UTC ---
Confirmed. Or use __builtin_absu() - bah you'd need to add it first ;)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/56085] Unsafe negation in C++03 pow(complex,int)
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-01-24 11:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-01-24 11:20:21 UTC ---
Thanks Marc for noticing, the core problem seems very old, but probably when it
belonged to __pow_helper was less visible because of (non-)inlining. Let's fix
this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/56085] Unsafe negation in C++03 pow(complex,int)
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-01-24 12:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085
--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2013-01-24 12:21:06 UTC ---
Author: paolo
Date: Thu Jan 24 12:20:57 2013
New Revision: 195421
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195421
Log:
2013-01-24 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/56085
* include/std/complex (pow(const complex<>&, int)): Avoid __n
signed overflow.
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/complex
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/56085] Unsafe negation in C++03 pow(complex,int)
2013-01-23 16:01 [Bug libstdc++/56085] New: Unsafe negation in C++03 pow(complex,int) glisse at gcc dot gnu.org
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-01-24 12:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.7.3
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-01-24 12:22:31 UTC ---
Fixed mainline and 4.7.3.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/56085] Unsafe negation in C++03 pow(complex,int)
2013-01-23 16:01 [Bug libstdc++/56085] New: Unsafe negation in C++03 pow(complex,int) glisse at gcc dot gnu.org
` (3 preceding siblings ...)
2013-01-24 12:22 ` paolo.carlini at oracle dot com
@ 2013-01-24 12:22 ` paolo at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-01-24 12:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56085
--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2013-01-24 12:21:33 UTC ---
Author: paolo
Date: Thu Jan 24 12:21:24 2013
New Revision: 195422
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195422
Log:
2013-01-24 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/56085
* include/std/complex (pow(const complex<>&, int)): Avoid __n
signed overflow.
Modified:
branches/gcc-4_7-branch/libstdc++-v3/ChangeLog
branches/gcc-4_7-branch/libstdc++-v3/include/std/complex
^ 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).