aboutsummaryrefslogtreecommitdiffstats
path: root/tests/keeping-unstable-ref/main.cpp
blob: d5d78c57301aca0f9262f12e5c86b0ca918cbacd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QMap>

QMap<int, int> getMap() {
    return {};
}


struct Foo {
    int *m = nullptr;
};

void test()
{
    QMap<int,int> map;
    map.insert(0, 0);
    int &a = map[0]; // Warn
    int b = map[0];

    int &c = b; //  OK

    int &d = getMap()[0]; // Warn
    //Foo f;
    //f.m = &map[0];
    int aa;
    map[0] = aa;
}