Bug 000315

When Created: 01/23/2000 00:00:57
Against DJGPP version: 2.02
By whom:
Abstract: A Strange External Variable "index" in DJGPP 2.02
#ifdef __DJGPP__

  What's this.
  where is this external float/integer/character/whatever variable 'index'
  Built into the compiler,

  3:42 PM 03/01/2000

  DJGPP Version 2.02

int main ( void )
  extern float index;     //Whatever you like uncomment
//  extern int   index;
//  extern char  index;

    return ++index;

Note added: 01/23/2000 11:00:42
By whom:
`index' is not a variable, it's a function.  You could do the same
with `sin' or `abort' or any other library function.  It's a perfectly
valid operation to increment "++index": it means you increment a pointer
to that function.

This is not a bug.  I'm closing this report.

Closed on 01/23/2000 11:00:53: It's a feature of the C language; not a bug.
By whom:

Note added: 01/24/2000 12:00:28
By whom:
Just to avoid some potential confusion: 'index' is a traditional 
UNIX library call, equivalent to 'strchr()'.

The example program is incorrect in itself, from the point of
view of Standard C, so it cannot be used to show a bug in the
compiler or library: It uses a variable declared as 'external', but doesn't 
link in any other file that defines it, even though 'index' is not defined 
by Standard C.

Anyway, I wonder how anyone could have missed the first thing to
try, in such a case: look up in the docs if anything called 'index'
is defined in the library:

	info libc alphabetic index

et voila: there you see that it exists, and what it is.

  webmaster     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010