public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106350] New: O3 memcpy warning when prepending a length-1 string literal to a constant std::string
@ 2022-07-19 0:10 me+gccbugzilla at s5 dot pm
2022-07-19 8:59 ` [Bug tree-optimization/106350] " redi at gcc dot gnu.org
2022-07-19 23:10 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: me+gccbugzilla at s5 dot pm @ 2022-07-19 0:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106350
Bug ID: 106350
Summary: O3 memcpy warning when prepending a length-1 string
literal to a constant std::string
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: me+gccbugzilla at s5 dot pm
Target Milestone: ---
Created attachment 53318
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53318&action=edit
Log produced by Compiler Explorer when using gcc (trunk)
The following code produces a warning under `-std=c++20 -O3 -Wrestrict`:
#include <string>
std::string memcpy_bug() {
return "x" + std::string("yz");
}
(1) If `"x"` is changed to be a string literal of any length other than 1, the
warning does not occur
(2) If `std::string("yz")` is pulled out into a variable (i.e. `std::string
var("yz");` and `return "x" + var;`) the warning does not occur
(3) If the optimization mode used is O1, O2, or Os, the warning does not occur
(4) If the compiler version is downgraded to GCC 11.3, the warning does not
occur
Appending a length-1 literal does not have this issue.
Attached is the log produced by Compiler Explorer on GCC trunk commit
c70a48a8f8f6a43b35f783b5672c9a3c0a363c31.
Possibly related to <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329>. I
made the decision to submit this independently due to (2), but I don't doubt
that it's likely a duplicate.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106350] O3 memcpy warning when prepending a length-1 string literal to a constant std::string
2022-07-19 0:10 [Bug c++/106350] New: O3 memcpy warning when prepending a length-1 string literal to a constant std::string me+gccbugzilla at s5 dot pm
@ 2022-07-19 8:59 ` redi at gcc dot gnu.org
2022-07-19 23:10 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-19 8:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106350
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105329
Component|c++ |tree-optimization
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think it is a dup of that one.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106350] O3 memcpy warning when prepending a length-1 string literal to a constant std::string
2022-07-19 0:10 [Bug c++/106350] New: O3 memcpy warning when prepending a length-1 string literal to a constant std::string me+gccbugzilla at s5 dot pm
2022-07-19 8:59 ` [Bug tree-optimization/106350] " redi at gcc dot gnu.org
@ 2022-07-19 23:10 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-19 23:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106350
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 105651.
*** This bug has been marked as a duplicate of bug 105651 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-19 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 0:10 [Bug c++/106350] New: O3 memcpy warning when prepending a length-1 string literal to a constant std::string me+gccbugzilla at s5 dot pm
2022-07-19 8:59 ` [Bug tree-optimization/106350] " redi at gcc dot gnu.org
2022-07-19 23:10 ` pinskia 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).