This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Implement Undefined Behavior Sanitizer


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]