Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. A cursed feature of C in 1972: Labels and functions were reassignable (i.e., lvalues)!

A cursed feature of C in 1972: Labels and functions were reassignable (i.e., lvalues)!

Scheduled Pinned Locked Moved Uncategorized
unixretrocomputingvintagecomputin
22 Posts 12 Posters 15 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • thalia@discuss.systemsT thalia@discuss.systems

    This snippet deliberately triggers a "Bus error -- Core dumped":

    int o1[];
    o1 = -3;
    *o1;

    From Dennis_Tapes/dmr/cgd/cg1.c:expr.

    aap@mastodon.sdf.orgA This user is from outside of this forum
    aap@mastodon.sdf.orgA This user is from outside of this forum
    aap@mastodon.sdf.org
    wrote last edited by
    #21

    @thalia Very interesting program too 🙂 did it ever up in anything later or was it more like an experiment?

    1 Reply Last reply
    0
    • thalia@discuss.systemsT thalia@discuss.systems

      A cursed feature of C in 1972: Labels and functions were reassignable (i.e., lvalues)!

      For example, this is a clever way to initialize once:

      goto init;
      init:
      ouptr = oubuf;
      init = init1;
      init1:

      which is compiled to:

      jmp *4120
      mov 4136,4144
      mov 4122,4120

      Note the indirect jump and assignment to that address. All gotos used indirect jumps. This apparently would have also worked with functions.

      #c #unix #retrocomputing #vintagecomputing

      sobex@social.sciences.reS This user is from outside of this forum
      sobex@social.sciences.reS This user is from outside of this forum
      sobex@social.sciences.re
      wrote last edited by
      #22

      @thalia Very cursed indeed !
      I'm glad this was removed before it ever got standardized. (Otherwise we'd still be stuck with it nowadays, right @thephd ?)

      1 Reply Last reply
      0
      • R relay@relay.mycrowd.ca shared this topic
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups