public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/114925] New: include/bits/fs_path.h#L841 deprecation note suggests UB @ 2024-05-02 15:07 fabian_kessler at gmx dot de 2024-05-02 15:17 ` [Bug libstdc++/114925] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: fabian_kessler at gmx dot de @ 2024-05-02 15:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114925 Bug ID: 114925 Summary: include/bits/fs_path.h#L841 deprecation note suggests UB Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fabian_kessler at gmx dot de Target Milestone: --- ``` template<typename _Source, typename _Require = __detail::_Path<_Source>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>> _GLIBCXX20_DEPRECATED_SUGGEST("path((const char8_t*)&*source)") inline path u8path(const _Source& __source) ``` This is clearly undefined behavior, since it breaks aliasing rules. Even if it's implementation vise ok, it might not be correct with other compilers. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114925] include/bits/fs_path.h#L841 deprecation note suggests UB 2024-05-02 15:07 [Bug libstdc++/114925] New: include/bits/fs_path.h#L841 deprecation note suggests UB fabian_kessler at gmx dot de @ 2024-05-02 15:17 ` pinskia at gcc dot gnu.org 2024-05-02 15:58 ` fabian_kessler at gmx dot de 2024-05-02 16:59 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-05-02 15:17 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114925 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I thought char8_t is still a character type so aliasing wise it falls under that rule. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114925] include/bits/fs_path.h#L841 deprecation note suggests UB 2024-05-02 15:07 [Bug libstdc++/114925] New: include/bits/fs_path.h#L841 deprecation note suggests UB fabian_kessler at gmx dot de 2024-05-02 15:17 ` [Bug libstdc++/114925] " pinskia at gcc dot gnu.org @ 2024-05-02 15:58 ` fabian_kessler at gmx dot de 2024-05-02 16:59 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: fabian_kessler at gmx dot de @ 2024-05-02 15:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114925 --- Comment #2 from fabian_kessler at gmx dot de <fabian_kessler at gmx dot de> --- (In reply to Andrew Pinski from comment #1) > I thought char8_t is still a character type so aliasing wise it falls under > that rule. Actually no. They are distinct types and only 4 types are allowed to alias everything. That's char, signed/unsigned char and std::byte. Consider the following function: ``` void cringe(char*& a, char8_t*& b){ b = u8"Hello There!" print(a); } ``` ``` int main(){ char8_t* obiwan = u8"Kenobi"; cringe((char*&)obiwan, obiwan); // Might output "Kenobi" instead of "Hello There!" } ``` That is, because the compiler is allowed to assume, that b can't alias a and no change can't happen to a in that function. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114925] include/bits/fs_path.h#L841 deprecation note suggests UB 2024-05-02 15:07 [Bug libstdc++/114925] New: include/bits/fs_path.h#L841 deprecation note suggests UB fabian_kessler at gmx dot de 2024-05-02 15:17 ` [Bug libstdc++/114925] " pinskia at gcc dot gnu.org 2024-05-02 15:58 ` fabian_kessler at gmx dot de @ 2024-05-02 16:59 ` redi at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2024-05-02 16:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114925 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-05-02 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- The suggestion is wrong anyway because _Source doesn't have to be a contiguous iterator, or any kind of iterator at all. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-02 16:59 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-05-02 15:07 [Bug libstdc++/114925] New: include/bits/fs_path.h#L841 deprecation note suggests UB fabian_kessler at gmx dot de 2024-05-02 15:17 ` [Bug libstdc++/114925] " pinskia at gcc dot gnu.org 2024-05-02 15:58 ` fabian_kessler at gmx dot de 2024-05-02 16:59 ` redi 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).