Re: No warning for no-op / no-ops / noop / noops / statements without effect?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff Donner <jeffrey.donner@xxxxxxxxx> writes:

>   How do you get no-ops to trigger a warning? Eg this:
>
> void noop()
> {
>    int i = 6;
>    i |= 0;
>
>    int j = 5;
>    j += 0;
>
>    int k = 3;
>    k = k;
> }
>
>> g++ -pedantic -Wall -Wextra -O3 -c noops.cpp
>>
>
> compiles without complaint. Am I just missing a flag? (4.1.x, 4.4.x, 4.6)

There is no general warning for no-ops.  I'm not aware of any warning
for |= 0 nor for += 0 nor for self-assignment.  The first two cases
don't seem common enough to warn about.  Warnings are generally intended
to catch code which is likely a mistake.  Is j |= 0 a likely mistake?
Hard to say, particularly if it is really

#ifndef O_BINARY
#define O_BINARY 0
#endif

  i |= O_BINARY;

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux