[COFF] [TUHS] C vs Pascal thoughts - was Buffer overflow found/fixed in v4 tape ; )

segaloco via COFF coff at tuhs.org
Wed Jan 7 03:08:29 AEST 2026


On Tuesday, January 6th, 2026 at 08:54, Dan Cross via COFF <coff at tuhs.org> wrote:

> On Tue, Jan 6, 2026 at 11:38 AM Paul Winalski via COFF coff at tuhs.org wrote:
> 
> > On Mon, Jan 5, 2026 at 5:31 PM Bakul Shah via COFF coff at tuhs.org wrote:
> > 
> > > 2.2 static variables -- I tend to believe using static vars is usually
> > > a mistake. Initialization -- saves some typing but that is about it.
> > 
> > Static variables are useful where a subroutine must retain context between
> > invocations. For example, the seed for a pseudo-random number generator.
> 
> 
> Surely one could do that with a global, as well.
> 
> - Dan C.

The distinction for me becomes a matter of safety.  A new developer on
the product poking around and changing random things is a lot more
likely to accidentally find and change a global from some random place
than to find and change a block-scoped static variable.  Static affords
no runtime checking of access, but it does ensure your compiler isn't
liable to be pimping out that pointer to other areas itself.  Granted,
you start passing around a pointer to that underlying static variable
and all bets are off.

- Matt G.


More information about the COFF mailing list