Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-18 Thread Jason Merrill
Ok, thanks. On Sun, Aug 18, 2019, 6:26 PM Marek Polacek wrote: > On Sun, Aug 18, 2019 at 08:37:14PM -0400, Marek Polacek wrote: > > Ok if that passes? > > Which it did. >

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-18 Thread Marek Polacek
On Sun, Aug 18, 2019 at 08:37:14PM -0400, Marek Polacek wrote: > Ok if that passes? Which it did.

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-18 Thread Marek Polacek
On Sun, Aug 18, 2019 at 05:08:07PM -0700, Jason Merrill wrote: > On 8/18/19 6:52 AM, Marek Polacek wrote: > > On Fri, Aug 16, 2019 at 05:40:39PM -0700, Jason Merrill wrote: > > > On 8/16/19 5:11 AM, Marek Polacek wrote: > > > > On Thu, Aug 15, 2019 at 08:21:25PM -0400, Jason Merrill wrote: > > > >

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-18 Thread Jason Merrill
On 8/18/19 6:52 AM, Marek Polacek wrote: On Fri, Aug 16, 2019 at 05:40:39PM -0700, Jason Merrill wrote: On 8/16/19 5:11 AM, Marek Polacek wrote: On Thu, Aug 15, 2019 at 08:21:25PM -0400, Jason Merrill wrote: On 8/15/19 5:34 PM, Marek Polacek wrote: On Wed, Aug 14, 2019 at 02:50:13PM -0400,

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-18 Thread Marek Polacek
On Fri, Aug 16, 2019 at 05:40:39PM -0700, Jason Merrill wrote: > On 8/16/19 5:11 AM, Marek Polacek wrote: > > On Thu, Aug 15, 2019 at 08:21:25PM -0400, Jason Merrill wrote: > > > On 8/15/19 5:34 PM, Marek Polacek wrote: > > > > On Wed, Aug 14, 2019 at 02:50:13PM -0400, Jason Merrill wrote: > > > >

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-16 Thread Jason Merrill
On 8/16/19 5:11 AM, Marek Polacek wrote: On Thu, Aug 15, 2019 at 08:21:25PM -0400, Jason Merrill wrote: On 8/15/19 5:34 PM, Marek Polacek wrote: On Wed, Aug 14, 2019 at 02:50:13PM -0400, Jason Merrill wrote: On Thu, Aug 8, 2019 at 3:25 PM Marek Polacek wrote: On Thu, Aug 08, 2019 at

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-16 Thread Marek Polacek
On Thu, Aug 15, 2019 at 08:21:25PM -0400, Jason Merrill wrote: > On 8/15/19 5:34 PM, Marek Polacek wrote: > > On Wed, Aug 14, 2019 at 02:50:13PM -0400, Jason Merrill wrote: > > > On Thu, Aug 8, 2019 at 3:25 PM Marek Polacek wrote: > > > > > > > > On Thu, Aug 08, 2019 at 11:06:17AM -0400, Jason

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-15 Thread Jason Merrill
On 8/15/19 5:34 PM, Marek Polacek wrote: On Wed, Aug 14, 2019 at 02:50:13PM -0400, Jason Merrill wrote: On Thu, Aug 8, 2019 at 3:25 PM Marek Polacek wrote: On Thu, Aug 08, 2019 at 11:06:17AM -0400, Jason Merrill wrote: On 8/6/19 3:20 PM, Marek Polacek wrote: On Mon, Aug 05, 2019 at

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-15 Thread Marek Polacek
On Wed, Aug 14, 2019 at 02:50:13PM -0400, Jason Merrill wrote: > On Thu, Aug 8, 2019 at 3:25 PM Marek Polacek wrote: > > > > On Thu, Aug 08, 2019 at 11:06:17AM -0400, Jason Merrill wrote: > > > On 8/6/19 3:20 PM, Marek Polacek wrote: > > > > On Mon, Aug 05, 2019 at 03:54:19PM -0400, Jason Merrill

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-14 Thread Jason Merrill
On Thu, Aug 8, 2019 at 3:25 PM Marek Polacek wrote: > > On Thu, Aug 08, 2019 at 11:06:17AM -0400, Jason Merrill wrote: > > On 8/6/19 3:20 PM, Marek Polacek wrote: > > > On Mon, Aug 05, 2019 at 03:54:19PM -0400, Jason Merrill wrote: > > > > On 7/31/19 3:26 PM, Marek Polacek wrote: > > > > > One of

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-08 Thread Marek Polacek
On Thu, Aug 08, 2019 at 11:06:17AM -0400, Jason Merrill wrote: > On 8/6/19 3:20 PM, Marek Polacek wrote: > > On Mon, Aug 05, 2019 at 03:54:19PM -0400, Jason Merrill wrote: > > > On 7/31/19 3:26 PM, Marek Polacek wrote: > > > > One of the features of constexpr is that it doesn't allow UB; and such

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-08 Thread Jason Merrill
On 8/6/19 3:20 PM, Marek Polacek wrote: On Mon, Aug 05, 2019 at 03:54:19PM -0400, Jason Merrill wrote: On 7/31/19 3:26 PM, Marek Polacek wrote: One of the features of constexpr is that it doesn't allow UB; and such UB must be detected at compile-time. So running your code in a context that

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-06 Thread Marek Polacek
On Tue, Aug 06, 2019 at 09:38:35PM +0200, Paolo Carlini wrote: > Hi, > > On 31/07/19 21:26, Marek Polacek wrote: > > +static void > > +modifying_const_object_error (tree expr, tree obj) > > +{ > > + location_t loc = cp_expr_loc_or_loc (expr, input_location); > > Nit: now we have

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-06 Thread Paolo Carlini
Hi, On 31/07/19 21:26, Marek Polacek wrote: +static void +modifying_const_object_error (tree expr, tree obj) +{ + location_t loc = cp_expr_loc_or_loc (expr, input_location); Nit: now we have cp_expr_loc_input_loc Paolo.

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-06 Thread Marek Polacek
On Mon, Aug 05, 2019 at 03:54:19PM -0400, Jason Merrill wrote: > On 7/31/19 3:26 PM, Marek Polacek wrote: > > One of the features of constexpr is that it doesn't allow UB; and such UB > > must > > be detected at compile-time. So running your code in a context that > > requires > > a constant

Re: C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-08-05 Thread Jason Merrill
On 7/31/19 3:26 PM, Marek Polacek wrote: One of the features of constexpr is that it doesn't allow UB; and such UB must be detected at compile-time. So running your code in a context that requires a constant expression should ensure that the code in question is free of UB. In effect, constexpr

C++ PATCH for c++/91264 - detect modifying const objects in constexpr

2019-07-31 Thread Marek Polacek
One of the features of constexpr is that it doesn't allow UB; and such UB must be detected at compile-time. So running your code in a context that requires a constant expression should ensure that the code in question is free of UB. In effect, constexpr can serve as a sanitizer. E.g. this