c3c icon indicating copy to clipboard operation
c3c copied to clipboard

`@ensure` doesn't work with macros

Open Book-reader opened this issue 7 months ago • 4 comments

<*
  @ensure @volatile_load(*&&false)
*>
macro void foo() {}

fn int main()
{
  foo();
  return 0;
}

expected behavior: the program crashes with the message ERROR: '@ensure "@volatile_load(*&&false)" violated.' like it does when it's a function actual behavior: the program runs without error.

when it's @require instead of @ensure it gives a correct error

C3 Compiler Version:       0.7.2 (Pre-release, Jan  1 1980 00:00:00)
Installed directory:       /nix/store/zqa3bqdpcv478x7q4s58sv50rk3r4x56-c3c-0.7.2/bin/
Git Hash:                  b83e57b952da736cfd46e361b3deed26fbe895b8
Backends:                  LLVM
LLVM version:              19.1.6
LLVM default target:       x86_64-unknown-linux-gnu

Book-reader avatar May 15 '25 04:05 Book-reader

Yes, and I see that fn works correctly as well.

lerno avatar May 15 '25 07:05 lerno

I forgot about this. This works properly for CONSTANT checks, but not runtime checks, and this was because the macros were the first ones to get checking and at the time my focus was on static checks.

lerno avatar May 19 '25 21:05 lerno

This is kind of a lot, so I need some time for it.

lerno avatar May 22 '25 07:05 lerno

Let's do this next cycle.

lerno avatar May 30 '25 08:05 lerno