Bug#527450: indent breaks C code ! (fwd)

View: New views
2 Messages — Rating Filter:   Alert me  

Bug#527450: indent breaks C code ! (fwd)

by Santiago Vila :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.

I received this from the Debian bug system.
[ Please keep the Cc: lines when replying. Thanks ].

---------- Forwarded message ----------
From: Xavier Bestel <xavier.bestel@...>
To: Debian Bug Tracking System <submit@...>
Date: Thu, 07 May 2009 17:39:32 +0200
Subject: Bug#527450: indent breaks C code !

Package: indent
Version: 2.2.10-1
Severity: important


Hi,

when feeding this line:

        a += - -1;

indent transforms it to:

        a += --1;

which hasn't the same meaning at all (instead of a unary minus on a negative constant, it's a predecrementation of a constant) and in this example isn't even legal C code.

It's quite a serious issue.

Thanks,
        Xav

[...]


_______________________________________________
bug-indent mailing list
bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent

RE: Bug#527450: indent breaks C code ! (fwd)

by Stephen Anderson-9 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

BTW,  

Replacing the 1 with a variable, "b" in this case, DOES compile and completely changes the behavior which is worse since you there is no compile error.

        a += - -b;

indent transforms it to:

        a += --b;

Which has a different outcome.

int main (int argc, void *argv[])
{
  int a = 20, b = 5;
  a += - -b;
  printf ("a: %d, b: %d\n", a, b);
  return 0;
}
Outputs:
a: 25, b: 5

While
int main (int argc, void *argv[])
{
  int a = 20, b = 5;
  a += --b;
  printf ("a: %d, b: %d\n", a, b);
  return 0;
}
Outputs:
a: 24, b: 4

smanders

-----Original Message-----
From: bug-indent-bounces+smanders=lvl7.com@... [mailto:bug-indent-bounces+smanders=lvl7.com@...] On Behalf Of Santiago Vila
Sent: Friday, May 08, 2009 5:52 AM
To: bug-indent@...
Cc: 527450-forwarded@...; Xavier Bestel
Subject: Bug#527450: indent breaks C code ! (fwd)

Hello.

I received this from the Debian bug system.
[ Please keep the Cc: lines when replying. Thanks ].

---------- Forwarded message ----------
From: Xavier Bestel <xavier.bestel@...>
To: Debian Bug Tracking System <submit@...>
Date: Thu, 07 May 2009 17:39:32 +0200
Subject: Bug#527450: indent breaks C code !

Package: indent
Version: 2.2.10-1
Severity: important


Hi,

when feeding this line:

        a += - -1;

indent transforms it to:

        a += --1;

which hasn't the same meaning at all (instead of a unary minus on a negative constant, it's a predecrementation of a constant) and in this example isn't even legal C code.

It's quite a serious issue.

Thanks,
        Xav

[...]


_______________________________________________
bug-indent mailing list
bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent




_______________________________________________
bug-indent mailing list
bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent