[Bug c/45358] New: =+ oddness

christian at leber dot de gcc-bugzilla@gcc.gnu.org
Fri Aug 20 15:11:00 GMT 2010


Hello,

there is a minor issue when =+ is used by accident instead of +=.

It is unfortunate there there is not even a warning, because this is a typo
that can cost lots and lots of time.
Furthermore it seems that =+ is was the old syntax in the old pre ANSI C.

=+ behaves like =
(mathematically it is of course the same, but the behavior is still wrong,
but there is also never a reason to write =+ instead of =)

#include <stdio.h>
int main(void) {
        int a=1,b=1;

        a += 2;
        b =+ 2;
        printf("a=%d b=%d\n",a,b);
        return 0;
}

(no warning, not even with -Wall)
a=3 b=2

It would be nice if future version could at least throw a warning.

Regards
Christian Leber


-- 
           Summary: =+ oddness
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christian at leber dot de
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45358



More information about the Gcc-bugs mailing list