Opened 12 months ago
Closed 6 months ago
#289 closed defect (fixed)
Invariant Failure in Static Assertion
Reported by: | ajbeach | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
The following compiles, but fails the invariant check:
// Check that the actual and declared length of array are the same. static_assert( SIZE == sizeof(array) / sizeof(array[0]), "Wrong Array Size" );
This is valid code, but for some reason fails the check after the box pass. I believe it is a combination of a polymorphic function in an expression that does not have an enclosing statement/function. It still compiles if invariants are off, so this could be a case where the invariants are too strict, but I expect something is going wrong in the workings of the ever confounding box pass.
(The work around seems to be to use sizeof on the array element type.)
Note:
See TracTickets
for help on using tickets.
This particular case is fixed but I don't think the underlying issue was actually fixed. I believe the offending code no longer reaches the box pass because
sizeof(?)
is nowsizeof(typeof(?))
and gets reduced to the type before the box pass so no incorrect hoisting occurs. A new issue can be opened if someone finds another way to get that bad code to the box pass.(I thought this was a repeat of #287 but it is yet another error coming from the same piece of code.)