[llvm-bugs] [Bug 31732] New: Clang does not warn when it deletes a function when C99 designated initializers is of non-original order

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 24 01:01:13 PST 2017


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

            Bug ID: 31732
           Summary: Clang does not warn when it deletes a function when
                    C99 designated initializers is of non-original order
           Product: clang
           Version: 3.9
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vladon at yandex-team.ru
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

How to reproduce:

```
#include <iostream>

struct Acc {
    int a;
};

struct Buu {
    int b;
};

struct Foo {
    const Acc& acc;
    Buu& buu;
};

void printInfo( const Foo& ) {
    std::cout << "hi!" << std::endl;
}

void call( Buu& buu ) {
    Acc acc = { 1 };
    Foo foo = {
        .acc = acc,
        .buu = buu,
    };
    std::cout << "before" << std::endl;
    printInfo( foo );
    std::cout << "after" << std::endl;
}
void noCall( Buu& buu ) {
    Acc acc = { 1 };
    Foo foo = {
        .buu = buu,
        .acc = acc,
    };
    std::cout << "before" << std::endl;
    printInfo( foo );
    std::cout << "after" << std::endl;
}

int main() {
    Buu buu = { 2 };
    call( buu );
    noCall( buu );
    return 0;
}
```

Repeats at least in 3.7.0 through 3.9.0.

Output:

```
before
hi!
after
before
after
```

Yes, it is not a C++ standard code, but Clang does not issue a compile error
when deleting the function call.

-- 
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/20170124/98d0a58c/attachment-0001.html>


More information about the llvm-bugs mailing list