Skip to content

[Clang] [CodeGen] Wrong code generation for extern reference #127475

@16bit-ykiko

Description

@16bit-ykiko

Minimal Reproducible Example:

/// src.cpp
#include <vector>

struct S {
    std::vector<int> c;
};

static S ls = {{1, 2, 3}};

S& s = ls;

/// main.cpp
#include <cstdio>
#include <vector>

struct S {
    std::vector<int> c;
};

extern S& s;

int main() {
    for (size_t i = 0; i < s.c.size(); i++) {
        printf("aaa\n");
    }

    for (auto& i : s.c) {
        printf("bbb\n");
    }
    return 0;
}

https://godbolt.org/z/W1YoYsMYh

Metadata

Metadata

Assignees

Labels

clang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"miscompilationregression

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions