🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1267

Template related bug

#1267
From: dececco
Date: Mon, 14 Dec 1992 17:52
69 lines
1762 bytes
in g++ 2.3.1, this template cause a syntax error
if the FOO symbol is *NOT* defined

template<class T> class Dup
{
public:
  Dup(T& t): _d(t) {};

  void Print() { _d.Print();}

#ifdef FOO
  int foo() 
  {
    a;
    b;
    c;
    d;
    f;
    g;
    h;
  }
#endif

private:
  T& _d;
};


While the following template compile fine (always with FOO not #defined):

template<class T> class Dup
{
public:
  Dup(T& t): _d(t) {};

  void Print() { _d.Print();}

#ifdef FOO
  int foo() { a; b; c; d; f; g; h;}
#endif

private:
  T& _d;
};


The problem is that if the text inside a #ifdef is longer than 6 lines,
the preprocessor, instead of leaving blank lines, put a 

# line file

directive, for the compiler; this directive, inside a class template,
cause a syntax error at the template instantiation time.

Maurizio


Maurizio De Cecco

Office					Home
NSL				
57-59 rue Lhomond 75005 Paris		44 rue Servan 75011 Paris
tel +33-(1)-43367750 			tel: +33-(1)-49299507 
fax +33-(1)-43365978			fax: +33-(1)-49299507 
email: dececco@nsl.fr                   email: dececco@birillo.gna.org

==> please use office e-mail for professional use only           <==
==> please use home e-mail for personal and Alice communications <==
==>          if you are in a hurry, use office e-mail            <==
Technical Details
Message-ID: <9212141552.AA05610@combray.nsl.fr>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!nsl.UUCP!dececco

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!nsl.UUCP!dececco
From: dececco@nsl.UUCP
Subject: Template related bug
Message-ID: <9212141552.AA05610@combray.nsl.fr>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 14 Dec 1992 17:52:37 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 70