Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wuninitialized for struct assignment from GNU C statement expression #41949

Closed
nickdesaulniers opened this issue Jul 12, 2019 · 5 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla c duplicate Resolved as duplicate

Comments

@nickdesaulniers
Copy link
Member

Bugzilla Link 42604
Resolution DUPLICATE
Resolved on Jul 18, 2019 15:08
Version trunk
OS All
Blocks #31177
CC @arndb,@DougGregor,@nathanchance,@Nathan-Huckleberry,@zygoloid,@serge-sans-paille,@stephenhines

Extended Description

Consider the following example:

void init(int*);

void foo(void) {
int i = ({
init(&i);
i;
});
}

struct widget {
int x, y;
};
void init2(struct widget*);

void bar(void) {
struct widget my_widget = ({
init2(&my_widget);
my_widget;
});
}

warning: variable 'my_widget' is uninitialized when used within its own initialization [-Wuninitialized]

It seems like it's ok to do so for non-aggregate types, but aggregates issue the warning. I think it should not be a warning here?

@nickdesaulniers
Copy link
Member Author

assigned to @Nathan-Huckleberry

@serge-sans-paille
Copy link
Collaborator

Same error, without GCC extension:

struct widget {
    int x, y;
};
void init2(struct widget*);

void bar(void) {
    struct widget my_widget = (init2(&my_widget), my_widget);
}

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jul 17, 2019

These examples are undefined in C++, but valid in C; we should probably just disable this warning in C. (Without doing a significantly more sophisticated analysis, it's going to be hard to get it right.)

@nickdesaulniers
Copy link
Member Author

WIP: https://reviews.llvm.org/D64678

@nickdesaulniers
Copy link
Member Author

*** This bug has been marked as a duplicate of bug #31177 ***

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

2 participants