[cfe-dev] GNU extensions - different behaviour of g++ and clang for taking address of temporary array

Aleksei Sidorin via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 19 10:30:45 PST 2018


Hi all,

Consider a test case:

#include<stdio.h>

typedefinta[];

voidprint(int*c) {
    printf("%d\n", c[0]);
}

intmain() {
    print(a{2});
return0;
}

`g++ -std=gnu++11 -fsyntax-only` fails to compile this code: "error: 
taking address of temporary array". However, clang accepts it without 
any warnings and there is no any ASan output for it. Could someone 
explain me if it a GCC or Clang issue?

-- 
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180219/d3713a4c/attachment.html>


More information about the cfe-dev mailing list