0

I tried to use astyle to format the code base I've to work with. When I use the option --add-brackets the executable is not identical (If I only use -t and/or -b the output is identical).

if(a) return b

is modified to

if(a)
{
     return b
}

So my question is. Does gcc generate the same output if I only add and/or delete braces (obviously only for one liners like above). I tried some simple test case but already got an bit identical executable.

azraiyl
  • 343
  • 2
  • 4
  • 11
  • 2
    it certainly shouldn't cause a change in compiler output. I suppose it is possible that astyle "fixed" a dangling else issue with a different result than you expected. But that's just a guess. – Evan Teran Jul 06 '10 at 15:38
  • 1
    If you already tested it, why the question? Didn't that answer your question? – jalf Jul 06 '10 at 15:39
  • What's your `gcc` command-line? Depending on options, there may be line-no related debugging information included in the output. – Aidan Cully Jul 06 '10 at 15:43
  • @jalf A few tests are not evidence, at least for me. – azraiyl Jul 06 '10 at 15:46
  • @Aidan the exectuable contains no debugging information. It's for an embedded target. The linker script is manually written (contains only text, ro, ... sections). – azraiyl Jul 06 '10 at 15:47
  • @azraiyl: true, it's not evidence. But it's hard to get a better answer. Unless someone picks through the entirety of the GCC codebase, no one can rule out that in *some* odd corner case, it might generate different code for the two cases. The best answer you're going to get is "not usually, because there is no semantic difference between the two, but who knows about all the obscure corner cases?" – jalf Jul 06 '10 at 16:00

1 Answers1

4

1, No

2, Use the - s flag to see the assembler ( or Using GCC to produce readable assembly? to get more readable assembler)

Community
  • 1
  • 1
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • Thanks to hits hint, I was able to find the problem. There was macro in the source which was using `__LINE__` as internal value. When astyle adds braces, obviously `__LINE__` may change as well and therefore the compiled output. – azraiyl Jul 07 '10 at 10:19