This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Implement Undefined Behavior Sanitizer
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, Marek Polacek <polacek at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 06 Jun 2013 08:17:14 -0400
- Subject: Re: [RFC] Implement Undefined Behavior Sanitizer
- References: <20130605175728 dot GD4160 at redhat dot com> <20130605191910 dot GV1493 at tucnak dot redhat dot com> <20130605193508 dot GX1493 at tucnak dot redhat dot com> <20130606060741 dot GY1493 at tucnak dot redhat dot com>
On 06/06/2013 02:07 AM, Jakub Jelinek wrote:
Jason, does
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3675.html#1457
apply just to C++11/C++14, or to C++03 too?
The committee hasn't said anything about which DRs since C++03 apply to
it. I take the position that most do, but not this one, since it is a
change to wording that doesn't exist in C++03.
In C++03 I see in [expr.shift]/2
"The value of E1 << E2 is E1 (interpreted as a bit pattern) left-shifted E2
bit positions; vacated bits are zero-filled. If E1 has an unsigned type,
the value of the result is E1 multiplied by the quantity 2 raised to
the power E2, reduced modulo ULONG_MAX+1 if E1 has type unsigned long,
UINT_MAX+1 otherwise." Is that the same case as C90 then, the wording seems
to be pretty much the same?
Yes, that's the same as C90.
what the current -std= makes as undefined behavior (though, because of DRs
that is somewhat fuzzy, pre-DR1457 C++11 vs. post-DR1457 C++11)
In contrast to the C++03 situation, the committee has been clear about
which DRs apply to C++11 and which to C++1y, and this one does apply to
C++11.
It's unfortunate that C and C++ have different rules here. I'm actually
inclined to agree with comment 48 from
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n834.htm that we should
have left the C90/C++98 rules alone, but I guess that comment was rejected.
Jason