https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #12 from Fedor Chelnokov ---
Related discussion: https://stackoverflow.com/q/77224270/7325599
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
Kyle Knoepfel changed:
What|Removed |Added
Resolution|--- |INVALID
Status|UNCONFIRMED
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #10 from Fedor Chelnokov ---
It seems that both libc++ and MS STL implement std::sort without a temporary
object passed to cmp, because they are fine with compiling the following code
in constant expression (where unrelated pointers
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #9 from Jonathan Wakely ---
The sketches above are completely untested (and incorrect) but just
demonstrating the ideas.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #8 from Jonathan Wakely ---
The standard only defines sorting in terms of comparisons on "every iterator i
pointing to the sequence", which seems to preclude using a temporary object on
the stack that is outside the sequence.
That
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
Xi Ruoyao changed:
What|Removed |Added
CC||xry111 at gcc dot gnu.org
--- Comment #7
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #6 from Andrew Pinski ---
https://github.com/gcc-mirror/gcc/blob/d9375e490072d1aae73a93949aa158fcd2a27018/libstdc%2B%2B-v3/include/bits/stl_algo.h#L1814
is exactly where a temp copy is created. Is that valid for std::sort, I am
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #5 from Andrew Pinski ---
With -fsanitize=address we get this at runtime:
```
=
==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fc69190003c
at pc
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
Kyle Knoepfel changed:
What|Removed |Added
Status|RESOLVED|UNCONFIRMED
Resolution|INVALID
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #3 from Kyle Knoepfel ---
@Andrew Pinski, yes I surmised as much. My difficulty, though, is in
understanding if this is the correct behavior according to the standard's
specification of std::sort, which presumably is reasonably
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
Andrew Pinski changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111685
--- Comment #1 from Andrew Pinski ---
IIRC this happens if the cmp is defined incorrectly.
12 matches
Mail list logo