tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.02k stars 48 forks source link

Bug with global variable initializer #207

Closed ChengCat closed 5 years ago

ChengCat commented 5 years ago
(def X (struct extern ((a (p void)))))

(def make-x (fn extern X (void)
  (def tmp (var auto X))
  tmp))

(def var-x (var extern X (make-x)))

With the above program, the compiler complains about:

error: unable to resolve pointer address in struct declaration
ChengCat commented 5 years ago

Sorry, this is actually a sound behaviour. The program compiles fine if changed to:

(def X (struct extern ((a (p void)))))

(def make-x (fn extern X (void)
  (def tmp (var auto X))
  (setf (: tmp a) (nullptr void))
  tmp))

(def var-x (var extern X (make-x)))