This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/86241] duplicate strlen-like snprintf calls not folded
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 21 Jun 2018 15:09:36 +0000
- Subject: [Bug tree-optimization/86241] duplicate strlen-like snprintf calls not folded
- Auto-submitted: auto-generated
- References: <bug-86241-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86241
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Unlike bug 86203, the test case here uses local variables for the results of
the calls to eliminate the possibility of aliasing between them and what the
char pointer points to.
More important, unlike strlen, the specification for snprintf is clear that the
%s argument must point to an object with a character type, so the kind of
aliasing that might be possible in the test case in bug 86203(*) would make the
call to snprintf undefined.
[*] I raised the question of the strlen aliasing in bug 86203 in WG14 and will
propose to tighten up the language to make it invalid.