1// { dg-do run } 2// { dg-options "-fsanitize=null -Wall -Wno-unused-variable -std=c++11" } 3 4typedef const long int L; 5 6int 7main (void) 8{ 9 int *p = 0; 10 L *l = 0; 11 12 int &r = *p; 13 auto &r2 = *p; 14 L &lr = *l; 15 16 // Try an rvalue reference. 17 auto &&r3 = *p; 18 19 // Don't evaluate the reference initializer twice. 20 int i = 1; 21 int *q = &i; 22 int &qr = ++*q; 23 if (i != 2) 24 __builtin_abort (); 25} 26 27// { dg-output "reference binding to null pointer of type 'int'(\n|\r\n|\r)" } 28// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } 29// { dg-output "\[^\n\r]*reference binding to null pointer of type 'const L'(\n|\r\n|\r)" } 30// { dg-output "\[^\n\r]*reference binding to null pointer of type 'int'(\n|\r\n|\r)" } 31