[Bug c/64639] missing warning by -Wunused-value in compound expressions

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 20 11:26:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64639

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
            Summary|false negative of           |missing warning by
                   |-Wunused-value              |-Wunused-value in compound
                   |                            |expressions

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Mikhail Maltsev from comment #5)
> > gets somehow transformed into
> > b = (a = 0B) != 0B;, 0;
> 
> Probably folding works this way. Anyway, I think, I can explain how the

It would be interesting to know if the above is a faithful representation of
the AST representation or the pretty-printer is printing something weird. As
printed, the code does not look right. If it is a faithful representation, it
would be great to know where this folding occurs (and disable it).

> P.S. I know, that it all might be obvious for most of you, but I'm just
> trying to get acquainted with GCC sources and (hopefully) do something
> useful for the project, while waiting for next stage1 (bugs being fixed
> during stage 4 are obviously not for newcomers).

It wasn't obvious to me at all. I think it is extremely useful to provide a
deep analysis of PRs. A good analysis makes other devs more inclined to take a
bug and fix it. If you were only to do that, it would already be a great
contribution.

The logic in the second branch is wrong. This made me think of another testcase
where it is even more obvious that there is a missing warning:

int *a;
int b;
void g();
void f() {
  b = (g(), (a = 0) != 0, 0);
  b = ((g(), (a = 0) != 0), 0);
  b = (g(), ((a = 0) != 0, 0));
}

We should get a warning in all three lines, but we only get it in the last one.


More information about the Gcc-bugs mailing list