[llvm-bugs] [Bug 25873] New: Assignment of structure being optimized out

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 17 11:59:03 PST 2015


            Bug ID: 25873
           Summary: Assignment of structure being optimized out
           Product: clang
           Version: trunk
          Hardware: All
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sunil_srivastava at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Following example shows a wrong optimization with current trunk (r255918)

#include <stdio.h>
struct point {
    float x, y;
    point() { x = 0.0f; y = 0.0f; }
struct p2 {
    point    a, b;
    p2(): a(), b() {}
int main() {
    p2 p,q;
    q.a.x = 1.0f;
    q.a.y = 2.0f;
    q.b = q.a; // set q.b to same as q.a
    p = q;     // hence p.a must be same as p.b
    printf( "p.a=( %f, %f ), p.b=( %f, %f )\n", p.a.x, p.a.y, p.b.x, p.b.y );

with -O, it gives

p.a=( 1.000000, 2.000000 ), p.b=( 0.000000, 0.000000 )

I have tried it on linux/pc, but I think other platforms have same issue.

It is a regression. 3.5 did not have this bug. I will pin down further as to
when it happened.

The problem does not show if x and y are ints.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151217/d6d261b6/attachment.html>

More information about the llvm-bugs mailing list