From: mrs@cygnus.com (Mike Stump)
Subject: Re:  labels added to symbol table without corresponding definitions
Organization: Gnus Not Usenet
Distribution: gnu
Date: Sat, 29 Aug 1992 19:25:32 GMT

Just about any other version of gcc cures this problem.  gcc 2.2.1
does, and gcc 2.3, when released will.

> Date: Thu, 25 Jun 92 08:39:22 PDT
> From: jmg@inference.com (Jeff Greif)
> Message-Id: <9206251539.AA02435@quaestor>
> Organization: Inference Corporation
> Address:      550 N. Continental Blvd., El Segundo, CA 90245-5052
> Phone:        (310) 322-0200
> To: bug-g++@prep.ai.mit.edu
> Cc: jaf@inference.com, da@inference.com, watmore@inference.com
> In-Reply-To: Greg Watmore's message of Wed, 24 Jun 92 17:34:55 PDT <9206250034.AA23152@quaestor>

> In submitting this bug report yesterday, we forgot to provide the header
> file that will enable you to reproduce it independently.  Sorry.  Please find
> it at the end of this message.

>    Date: Wed, 24 Jun 92 17:34:55 PDT
>    From: watmore (Greg Watmore)

>    gcc2.2.2 with corresponding g++2.2.2 on Sun4 OS 4.1.1:

>    The file below, called tmp.cxx, produces the following undefined symbols
>    when compiled and linked.  These are internal labels which get .stabn records
>    defined for them although they are not defined in the .s file.
>    The labels have something to do with the end of the extern "C" part, probably.

>    Compiler script and messages:

>    g++  -g3 -static -I. -W -Wreturn-type -Wcomment tmp.cxx
>    Undefined
>    LBE6
>    LBB6
>    collect: /usr/bin/ld returned 2 exit status

>    Source file tmp.cxx:

>    extern "C"{
>    #include <stdio.h>
>      typedef void* art_rest_ptr;
>      typedef void* art_object;
>    #include "varkeys.h"

>      art_object a_nil = NULL;
>      int a_rest_length(art_rest_ptr) {return 0;}
>      art_object a_art_rest_value(art_rest_ptr,int) {return a_nil;}

>    art_object a_map_row_to_object(art_object a1, art_object a2, ...);
>    art_object di_map_row_to_object_keys(art_object a1, art_object a2, art_rest_ptr extra);
>    }


>    static art_object map_row_to_object(art_object statement, art_object subquery, rest_arg_array *args);

>    main()
>    {
>      return -1;
>    }

>    art_object a_map_row_to_object(art_object a1, art_object a2, ...) 
>    {
>      art_object ret;
>      VARARGS_TO_ARRAY(args, a2)	
>      ret = map_row_to_object(a1, a2, &args);
>      return ret;
>    }

>    art_object di_map_row_to_object_keys(art_object a1, art_object a2, art_rest_ptr extra)
>    {
>      art_object ret;
>      REST_PTR_TO_ARRAY(args, extra);

>      ret = map_row_to_object(a1, a2, &args);

>      return ret;
>    }


>    static art_object map_row_to_object(art_object statement, art_object subquery, rest_arg_array *args)
>    {
>      return a_nil;
>    }

> -----------------------------------------------------------------------
> varkeys.h:
> -----------------------------------------------------------------------

> #ifndef ARRAY_VARARG_AND_KEY_MACROS
> #define ARRAY_VARARG_AND_KEY_MACROS

> /****************************************************************************
>  VARARGS_TO_ARRAY(args, last_req_arg);
>  REST_PTR_TO_ARRAY(args, rest_ptr);
>  array_art_rest_value(args, i);
>  arg =array_art_key_value(args, a_art_symbol("key"), a_art_symbol("default");
> ****************************************************************************/

> #include <stdarg.h>

> #define MAX_ARGS_FOR_C_OR_ART_FUNCTION 255

> typedef struct{
>   art_object array[MAX_ARGS_FOR_C_OR_ART_FUNCTION];
>   int count;
> } rest_arg_array;

> #define stuff_rest_arg_array_from_va_list(ap, arg_array) \
>   for (arg_array.count = 0; \
>     arg_array.array[arg_array.count] = va_arg(ap,art_object); \
>     ++arg_array.count)

> #define VARARGS_TO_ARRAY(arg_struct, last_required_arg) \
>   rest_arg_array arg_struct; \
>   va_list ap;\
>   va_start (ap, last_required_arg);\
>   stuff_rest_arg_array_from_va_list(ap,arg_struct); \ 
>   va_end(ap);

> #define stuff_rest_arg_array_from_rest_ptr(rp,arg_struct) \
>   {  int i; \
>      for (i=1; i<=(arg_struct.count); i++) \
>        arg_struct.array[(i)-1] = a_art_rest_value(rp,i); \
>   }

> #define REST_PTR_TO_ARRAY(arg_struct, rest_ptr) \
>   rest_arg_array arg_struct; \
>   arg_struct.count = a_rest_length(rest_ptr);\
>   stuff_rest_arg_array_from_rest_ptr(rest_ptr, arg_struct)

> #endif /* ARRAY_VARARG_AND_KEY_MACROS */




Newsgroups: gnu.g++.bug