[cfe-dev] [Analyzer] Question about casting a symbol to union

Artem Dergachev via cfe-dev cfe-dev at lists.llvm.org
Wed Jun 26 14:42:27 PDT 2019


Unions are generally wonky (we even listed them on 
http://clang-analyzer.llvm.org/open_projects.html) (see also 
http://lists.llvm.org/pipermail/cfe-dev/2017-March/052881.html).

Additionally, such direct cast from struct rvalue to union rvalue is a 
GCC extension rather than valid C. It shouldn't be hard to implement, 
but it's definitely not on the top of my to-do list.

Your questions indicate to me that you're trying to do something weird. 
I'd much rather try to help with the original problem by recommending 
the overall solution that'll most likely work.

On 6/26/19 12:42 PM, Torry Chen via cfe-dev wrote:
> My program has struct to union casting and I'm writing a checker for 
> some of the union types. One issue I noticed is that in checkBind the 
> SVal for the Value part seems to be lost (see sample below). Is this a 
> known issue about casting to union? How can I get the symbol from the 
> union casting assignment (e.g., Val -> conj_$3)?
>
> struct XY {
>   uint64_t X;
>   uint64_t Y;
> };
>
> union Pos {
>   struct XY xy;
> };
>
> // checkBind: Loc -> xy1, Val -> conj_$3{struct XY, LC1, S12330, #1}
> struct xy1 = next_pos(12, 13); // implementation of next_pos is 
> unknown to CSA
>
> // checkBind: Loc -> pos1, Val -> Unknown
> union Pos pos1 = (union Pos)next_pos(12, 13);
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

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


More information about the cfe-dev mailing list