https://bugs.llvm.org/show_bug.cgi?id=41178

            Bug ID: 41178
           Summary: clang strict-aliasing optimizations vs unreachable
                    code
           Product: libraries
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 21640
  --> https://bugs.llvm.org/attachment.cgi?id=21640&action=edit
test with unreachable code

Lets consider example r.c from attachment

$ clang-7.0 -O0 r.c -o r0.out
$ clang-7.0 -O1 r.c -fno-strict-aliasing -o r1.nsa.out
$ clang-7.0 -O1 r.c -o r1.sa.out

$ ./r0.out
this should be zero: 0

$ ./r1.nsa.out
this should be zero: 0

$ ./r1.sa.out
this should be zero: -1


static inline void __attribute__((always_inline)) longLongAssign( int cond,
char *ptr)
{
    if ( cond )
    {
        *((long long *)ptr) = 0;
    }
}

I suppose test doesn't violate strict-aliasing rule, because
1) argument "ptr" has type "char *"
2) condition "cond" is always zero

Why I got different results?

P.S. I am new therefore apologize for my mistakes.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to