[cfe-dev] [PATCH] Sema: Fix CheckReturnStackAddr when RetValExp is an explicit cast
Chongyu Zhu
lembacon at gmail.com
Fri Nov 8 00:45:15 PST 2013
Hi,
I have found that `Sema::CheckReturnStackAddr` failed to generate warnings for `diag::warn_ret_stack_ref` and `diag::warn_ret_local_temp_ref` when the return value expression is an explicit cast.
Provided the following code,
> const int &test1()
> {
> return 0;
> }
>
> const int &test2()
> {
> int val = 0;
> return val;
> }
>
> const int &test3()
> {
> return static_cast<const int &>(0);
> }
>
> const int &test4()
> {
> int val = 0;
> return static_cast<const int &>(val);
> }
Clang (as of r194251) generates warnings for `test1` and `test2`, however, no warnings are given for `test3` and `test4`.
GCC (4.8.1) is able to successfully generate warnings for all of the above.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sema_eval_val.patch
Type: application/octet-stream
Size: 912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131108/1f0c6dea/attachment.obj>
-------------- next part --------------
Regards,
Chongyu Zhu
More information about the cfe-dev
mailing list