[cfe-dev] Clang happily ignoring an attribute

via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 17 23:00:07 PDT 2018


Hello everyone,

currently I'm checking if some functions are inlined with clang or not. 
Because of that I have a lot of unused variables storing return values - 
but clang optimizes them away including the function. Even "volatile" 
didn't stopped Clang from doing so. So I tried using the GCC attribute 
"used". But clang just responses:

1>main.cpp(9,23): warning : 'used' attribute ignored 
[-Wignored-attributes]
1>          void* __attribute__((used)) adr = _ReturnAddress();

Why is clang doing this? And how can I prevent him easily from optimizing 
my values without referencing them?

Kind greetings
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, 
USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, 
Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180418/35c685de/attachment.html>


More information about the cfe-dev mailing list