[Bug libstdc++/63345] Multiple undefined behaviors (static_cast<>) in libstdc++-v3/include/bits

2018-11-19 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

Jonathan Wakely  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=66017
 Resolution|--- |FIXED
   Target Milestone|--- |6.0

--- Comment #13 from Jonathan Wakely  ---
Yes, all fixes should be present in gcc-6.1 and up.

[Bug libstdc++/63345] Multiple undefined behaviors (static_cast<>) in libstdc++-v3/include/bits

2018-11-19 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

Martin Liška  changed:

   What|Removed |Added

 CC||marxin at gcc dot gnu.org

--- Comment #12 from Martin Liška  ---
Can the bug be marked as resolved?

[Bug libstdc++/63345] Multiple undefined behaviors (static_cast<>) in libstdc++-v3/include/bits

2016-04-06 Thread malcolm.parsons at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #11 from Malcolm Parsons  ---
(In reply to Jonathan Wakely from comment #10)
> > The attached patch fixes it for me.
> 
> That seems to be a backport of r223746 from trunk, right? I'll look into
> applying that to the gcc-5 branch.

It looks like it.  Thanks.

[Bug libstdc++/63345] Multiple undefined behaviors (static_cast<>) in libstdc++-v3/include/bits

2016-04-06 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #10 from Jonathan Wakely  ---
(In reply to Malcolm Parsons from comment #9)
> Created attachment 38201 [details]
> fix undefined behaviour in stl_tree.h
> 
> (In reply to Jonathan Wakely from comment #8)
> > I believe all the real problems are fixed now.
> 
> Clang 3.8.0 still reports undefined behaviour in stl_tree.h using GCC 5.3.0:
> 
> lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/
> stl_tree.h:1910:28: runtime error: upcast of address 0x0225d260 with
> insufficient space for an object of type 'std::_Rb_tree_node >'
> 0x0225d260: note: pointer points here
>  00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  60 d2 25 02
> 00 00 00 00  60 d2 25 02
>   ^ 

That's expected, as some of the fixes are only on trunk, not the gcc-5 branch.

> The attached patch fixes it for me.

That seems to be a backport of r223746 from trunk, right? I'll look into
applying that to the gcc-5 branch.

[Bug libstdc++/63345] Multiple undefined behaviors (static_cast<>) in libstdc++-v3/include/bits

2016-04-06 Thread malcolm.parsons at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

Malcolm Parsons  changed:

   What|Removed |Added

 CC||malcolm.parsons at gmail dot 
com

--- Comment #9 from Malcolm Parsons  ---
Created attachment 38201
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38201=edit
fix undefined behaviour in stl_tree.h

(In reply to Jonathan Wakely from comment #8)
> I believe all the real problems are fixed now.

Clang 3.8.0 still reports undefined behaviour in stl_tree.h using GCC 5.3.0:

lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/stl_tree.h:1910:28:
runtime error: upcast of address 0x0225d260 with insufficient space for an
object of type 'std::_Rb_tree_node'
0x0225d260: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  60 d2 25 02 00
00 00 00  60 d2 25 02
  ^ 

The attached patch fixes it for me.

[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2015-07-13 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #8 from Jonathan Wakely redi at gcc dot gnu.org ---
I believe all the real problems are fixed now.


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2015-05-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #7 from Jonathan Wakely redi at gcc dot gnu.org ---
Why does your patch need to touch operator* or operator- for any of the
iterators? For any dereferenceable iterator the cast should be valid, so if
you're seeing invalid casts it suggests that you are dereferencing invalid
iterators.


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-10-13 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #6 from Marc Glisse glisse at gcc dot gnu.org ---
Author: glisse
Date: Mon Oct 13 10:00:27 2014
New Revision: 216142

URL: https://gcc.gnu.org/viewcvs?rev=216142root=gccview=rev
Log:
2014-10-13  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/61347
PR libstdc++/63345
* include/bits/list.tcc (_List_base::_M_clear()): Delay cast so it
isn't done for the sentinel.
* include/bits/stl_list.h (_List_base::_M_size): Move...
(_List_base::_List_impl::_M_node): ... here.
(_List_base::_M_get_size(), _List_base::_M_set_size(size_t),
_List_base::_M_inc_size(size_t), _List_base::_M_dec_size(size_t),
_List_base::_M_node_count): Adapt to the move.
* 23_containers/list/requirements/dr438/assign_neg.cc: Update
line number.
* 23_containers/list/requirements/dr438/constructor_1_neg.cc: Likewise.
* 23_containers/list/requirements/dr438/constructor_2_neg.cc: Likewise.
* 23_containers/list/requirements/dr438/insert_neg.cc: Likewise.


Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/list.tcc
trunk/libstdc++-v3/include/bits/stl_list.h
   
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-09-23 Thread blee at gatech dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #1 from Byoungyoung Lee blee at gatech dot edu ---
Created attachment 33541
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33541action=edit
Error reports in running Chromium browsers.


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-09-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-09-23
 Ever confirmed|0   |1

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org ---
Thanks for the report, I'll go through the fixes and apply them (some of them
conflict with changes I'm working on in stl_list.h and stl_tree.h)


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-09-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #3 from Marc Glisse glisse at gcc dot gnu.org ---
Hello,

thanks for the report. I don't think we should blindly replace static_cast with
reinterpret_cast but rather try and understand what is going on. For instance,
for std::list, I believe the only case where the cast is wrong is for the
sentinel, and we should find a way not to cast at all in that case (it might be
enough to move the cast inside the loop).


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-09-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org ---
(In reply to Marc Glisse from comment #3)
 thanks for the report. I don't think we should blindly replace static_cast
 with reinterpret_cast but rather try and understand what is going on.

Yes, I strongly agree.


[Bug libstdc++/63345] Multiple undefined behaviors (static_cast) in libstdc++-v3/include/bits

2014-09-23 Thread blee at gatech dot edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345

--- Comment #5 from Byoungyoung Lee blee at gatech dot edu ---
Thank you for the quick response! The patch I've uploaded is simply the results
by replacing all static_cast in the error reports with reinterpret_cast, so
that the tool stops complaining and it servers as more like a pointer where the
undefined happens. Please let me know if there's anything that I can help out
(i.e., regression testing).

Thanks!