steakhal added a comment.

In D48866#1527540 <https://reviews.llvm.org/D48866#1527540>, @lebedev.ri wrote:

> In D48866#1527506 <https://reviews.llvm.org/D48866#1527506>, @steakhal wrote:
>
> > The problem with the `-Wcast-align` is that it will only fire for C-style 
> > bitcast expressions, not for `reinterpret_cast` ones. example 
> > <https://godbolt.org/z/cm3S96>
> >  Does anyone know why is that behavior?
>
>
> Because `reinterpret_cast` is by definition allowed to perform these casts, 
> so it is assumed that no warning should be issued.
>  This part of the check i look forward to.


I still don't understand why should `-Wcast-align` issue warning only for 
c-style casts. What is the difference in the given example? What are the 
related paragraphs in the standard?
I assume in the example we violated the basic.lval/11 
<http://eel.is/c++draft/basic.lval#11> paragraph, so neither of those pointers 
are safely dereferencable.

In case we are casting from **char* ** we don't know what is the **dynamic 
type** of the object (same with std::byte, void * etc.). From my point of view 
the style of the cast is not important in this case, only the fact that both 
are performing bitcasts.
Have I missed something?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D48866/new/

https://reviews.llvm.org/D48866



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to