summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wdangling-reference13.C
blob: bc09fbae22babe68575f58ba99745f1df5559830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// PR c++/109774
// { dg-do compile }
// { dg-options "-Wdangling-reference" }

int y;

template<typename T>
int& get(const char& )
{
    return y;
}

int& get2(const char&)
{
    return y;
}

int stuff(void)
{
    const int &h = get<void>(0); // { dg-bogus "dangling reference" }
    const int &k = get2(0); // { dg-bogus "dangling reference" }
    return h+k;
}