delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/04/03:16:24

From: "Aleksey Kondratyev" <akondra AT no-spam-mv DOT ru>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP 2.8.0 labels as values problem
Date: Thu, 4 Jun 1998 11:05:12 +0400
Organization: Middle Volga Communication service
Lines: 44
Message-ID: <6l5h74$jio$1@simtel.ru>
NNTP-Posting-Host: ppp13.usr.mv.ru
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello DJGPP users,

I have a problem using labels as values gcc extension
in a c++ module. The following sample was compiled
fine by DJGPP 2.7.2.1but 2.8.0 version complains on
"Error: sorry, not implemented: initializer contains
unrecognized tree code".

#include <fstream.h>
#define ADD 0
#define SUB 1
template<class T>
T do_it(T a,T b,int op) {
    static void *oops[]={&&op_add,&&op_sub};
    goto *oops[(const int)op];
    op_add:
      return a+b;
    op_sub:
      return a-b;
}
int main() {
  cout<<do_it(2,2,ADD)<<'\n'<<do_it(2,2,SUB);
  return 0;
}

It is compiled fine without 'templates' but avoiding
of a template in my real module is quite difficult.
Please, suggest something!
E.g., is it be possible to declare labels in g++
beforehand?

----------------------------------------------------------------------
Aleksey Kondratyev
Ph.D. student of Ulyanovsk state University, Russia
http://www.mv.ru/~akondra
E-mail akondra AT mmf DOT univ DOT simbirsk DOT su
           akondra AT no-spam-mv DOT ru
           Remove "no-spam-" when replying






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019