[llvm] Delete the incorrect assert that assumes size of `APFloat` is the same as `IEEEFloat`. (PR #111780)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 20:17:14 PDT 2024


Ariel-Burton wrote:

> > > not all the members of APFloat is IEEE.
> > 
> > 
> > Oh I see. Do you add a new impl whose size is larger than `detail::IEEEFloat`?
> 
> If so, at least we can assert `sizeof(APFloat) == sizeof(APFloat::Storage)`.

That's an interesting idea, but needs care to get it to work because if the assert is APFloat it won;t compile because APFloat isn't complete until after the closing brace.  We could add a new `friend class APFloarChecker` to `APFloat` and do the check in that new class.  Something like this:

```
lass APFloat {
  union S {
    int i;
    long l;
  } s;
  friend class APFloatChecker;
};

class APFloatChecker {
  static_assert(sizeof(APFloat) == sizeof(APFloat::S));
};
```

`APFloatChecker` wouldn't need to go in the `.h`, where the assertion is evaluated every time the file is processed.  It could go in the `.cpp`, where it will be evaluated once per build.

https://github.com/llvm/llvm-project/pull/111780


More information about the llvm-commits mailing list