[cfe-dev] Crash on alignments >= 2**16 (PR26444)

don hinton via cfe-dev cfe-dev at lists.llvm.org
Sun Feb 14 13:30:57 PST 2016


Sema::AddAlignment() defines MaxValidAlignment like this:

  // Alignment calculations can wrap around if it's greater than 2**28.
  unsigned MaxValidAlignment =
      Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
                                                              : 268435456;

But AggValueSlot stores Alignment as an unsigned short:

class AggValueSlot {
...
  unsigned short Alignment;

The max value for an unsigned short is 2**16 -1, but you are passing
2**16, which AddeAlignment says is okay.  However, it ends up getting
stored as 0 in an unsigned short.

The fix is to make these sizes consistent, but I'm not sure which
should be changed  (though I'm guessing Alignment should be unsigned
instead of unsigned short).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160214/906d5070/attachment.html>


More information about the cfe-dev mailing list