Skip to content

bug? #2643

@regehr

Description

@regehr
Bugzilla Link 2271
Resolution FIXED
Resolved on May 01, 2008 14:14
Version unspecified
OS Linux
CC @sunfishcode

Extended Description

Assuming integer types are 2's complement, the attached code appears to have well-defined behavior. If I am misunderstanding something about C arithmetic then I apologize profusely for wasting peoples' time. The source should be small enough that someone can check this out relatively quickly.

With LLVM from recent svn on x86-32 I get the following:

[regehr@babel tmp1]$ llvm-gcc -O0 -fwrapv small.c ; ./a.out
foo
[regehr@babel tmp1]$ llvm-gcc -O1 -fwrapv small.c ; ./a.out
bar

For what it's worth "foo" is what gcc prints at all optimization levels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions