[llvm-bugs] [Bug 33065] false(?) -Wsequence warning

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 29 06:01:58 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33065

Michael Matz <matz at suse.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---
                 CC|                            |matz at suse.de

--- Comment #7 from Michael Matz <matz at suse.de> ---
(In reply to James Y Knight from comment #5)
> The standard says (C11 section 6.7.9 para 23):
> 
> > The evaluations of the initialization list expressions are indeterminately sequenced with respect to one another and thus the order in which any side effects occur is unspecified.152)
> 
> > 152) In particular, the evaluation order need not be the same as the order of subobject initialization
> 
> 
> This is independent of the "6.7.8 par 19" quoted (which is now 6.7.9 para 19)

While I agree this could be read that way (though I find that overly aggressive
reading), the rest is wrong.  First:

> Further, there is not a sequence point between these, as an initializer in a
> compound literal is not a "full expression".

This is no compound literal, it's an initializer.

And second:

> "Full expression" does actually
> (perhaps surprisingly) seem to mean what it sounds like it should.
>
> From C11 6.8 para 4: 
> > A full expression is an expression that is not part of another expression or of a declarator.

While the citation is of course correct, it doesn't apply here.  The
initializer
is not part of a declarator (it is part of a declaration; expressions in
declarators are things like array sizes). Hence the expressions in the
initializer-list are full expressions (as they clearly aren't part of other
expressions either), and so the sequence point rule
between full expressions applies and clangs warning is wrong.

Reopening because of this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170529/aa03b951/attachment-0001.html>


More information about the llvm-bugs mailing list