[cfe-dev] Miscompilation of sizeof

David Blaikie dblaikie at gmail.com
Sat Dec 10 13:41:00 PST 2011


Did you mean to attach a patch showing the assert you intend to add?

On Sat, Dec 10, 2011 at 12:52 PM, Abramo Bagnara
<abramo.bagnara at gmail.com> wrote:
>
> Ping.
>
> >
> > In ASTContext:::getTypeInfo(const Type *T) const we have:
> >
> >   uint64_t Width=0;
> >
> >   case Type::ConstantArray: {
> >     const ConstantArrayType *CAT = cast<ConstantArrayType>(T);
> >
> >     std::pair<uint64_t, unsigned> EltInfo =
> > getTypeInfo(CAT->getElementType());
> >     Width = EltInfo.first*CAT->getSize().getZExtValue();
> >
> > But this multiplication can overflow (because for reasons that I don't
> > known getTypeInfo return width specified in bits).
> >
> > If there are no objections I'd add an assert: probably we'll induce some
> > crashes, but I believe that this would be *far* better than to
> > miscompile the code (and assertions will be triggered only when code
> > would be miscompiled).
> >
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list