[cfe-dev] [RFC] Should an illegal C++11 memory model in an atomic op be an error?

Richard Smith richard at metafoo.co.uk
Mon Feb 2 17:07:02 PST 2015


On Mon, Feb 2, 2015 at 1:50 PM, Tim Northover <tnorthover at apple.com> wrote:

> > I'd be in favor or promoting it to an error. We recently started
> rejecting this code, for example:
>
> I'm not sure I would. Deciding on the diagnostics for our own intrinsics
> is one thing, but this would trigger on well-formed programs according to
> the standard.
>

I agree that this should not be an error. The builtin does not require a
constant; we shouldn't say it's ill-formed if we happen to be able to
evaluate the order parameter and find it's out-of-range.

I think this sort of thing is completely reasonable (perhaps in the
implementation of a C++11-compatible atomics library):

#define atomic_builtin(kind, order, ...) \
  ({ switch(order) { \
    case memory_order_relaxed: kind(__VA_ARGS__, __ATOMIC_RELAXED); break; \
    [...]

That's rather a bigger step to take, and we should probably be comparing it
> to situations with that similarity (the only one I know of is ARM64
> complaining more strongly about functions without prototypes).
>
> Cheers.
>
> Tim.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150202/4e41dd73/attachment.html>


More information about the cfe-dev mailing list