[PATCH] Sema: reject probably incorrect atomic ordering requests

JF Bastien jfb at google.com
Tue Mar 11 13:28:17 PDT 2014


Now that I think of it, Sema knowing that something is unreachable for sure
doesn't help, since the problem is with UB code that can't be proven
unreachable.


On Tue, Mar 11, 2014 at 1:21 PM, JF Bastien <jfb at google.com> wrote:

> What I mean is: does each Sema check has to deal with this (and pessimize
> all errors to warnings), or should Sema figure out what code isn't
> reachable?
>
>
> On Tue, Mar 11, 2014 at 1:07 PM, Richard Smith <richard at metafoo.co.uk>wrote:
>
>> Per C11 7.1.4/1, providing an invalid value for a library function
>> argument results in undefined behavior, and it's generally accepted that we
>> can only reject a program that has undefined behavior if the undefined
>> behavior is guaranteed to occur (either because it occurs during
>> translation or because it occurs on every execution of the program). So an
>> error is not allowed here, but a warning is fine.
>>
>>
>> On Tue, Mar 11, 2014 at 12:38 PM, JF Bastien <jfb at google.com> wrote:
>>
>>> Isn't that the case with any errors that can crop up in control-flow
>>> sensitive manners, through template magic or tautological compares and
>>> such? I assume David has a better informed opinion on this than I do.
>>>
>>>
>>> On Tue, Mar 11, 2014 at 12:21 PM, Tim Northover <t.p.northover at gmail.com
>>> > wrote:
>>>
>>>> Hi JF,
>>>>
>>>> Thanks for taking a look.
>>>>
>>>> On 11 March 2014 04:59, JF Bastien <jfb at google.com> wrote:
>>>> > lgtm after adding tests of missing __c11_atomic_* to
>>>> test/Sema/atomic-ops.c,
>>>> > especially load_n/store_n.
>>>>
>>>> I committed it with a full set of tests (r203561), and then changed it
>>>> to a warning (r203564) when I realised valid programs could contain
>>>> statements like:
>>>>
>>>> if (0) {
>>>>   __c11_atomic_load(ptr, memory_order_release);
>>>> }
>>>>
>>>> or possibly even some sane equivalent via templates or other weirdness.
>>>>
>>>> Cheers.
>>>>
>>>> Tim.
>>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140311/d28ef94a/attachment.html>


More information about the cfe-commits mailing list