473,387 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Illegal code?

Hello everybody,

(Disclaimer: I do not understand C++ templates.)

I've tried to make a testcase from the original code.

GCC 3.3.5 compiles with no warning, while GCC 3.4.3 rejects it. Could
somebody tell me if it because the code is illegal, and GCC 3.4.3's
stricter parser now rejects it, or is it some kind of regression?

$ g++-3.3.5 -c -Wall -ansi -pedantic foo.cxx
/* NO WARNING */

$ g++-3.4.3 -c -Wall -ansi -pedantic foo.cxx
foo.cxx: In member function `void WN_TREE_ITER< PRE_ORDER,
WHIRL>::WN_TREE_next()':
foo.cxx:53: error: `_wn' undeclared (first use this function)
foo.cxx:53: error: (Each undeclared identifier is reported only once for
each function it appears in.)

$ cat foo.cxx
typedef int WN;

typedef struct wn_iter {
WN *wn; /* current tree node */
} WN_ITER;

enum TRAV_ORDER {
PRE_ORDER=0,
POST_ORDER=1
};

// ================================================== ====================
// Base class shared by both traversal order interators
// We need this to get partial specialization work
// ================================================== ====================

template <typename WHIRL>
class WN_TREE_ITER_base
{
protected:
WHIRL _wn; // whirl node to iterate over;

public:
WHIRL Wn(void) const {return _wn;}
void Set_wn(WHIRL wn2) { _wn = wn2;}
WN_TREE_ITER_base(): _wn(0) {}
WN_TREE_ITER_base (WHIRL wn2) : _wn(wn2) {}
}; // class WN_TREE_ITER_base

// dummy template to parameterize the traversal order.
// only the specialized versions defined below are used.
template <TRAV_ORDER order, class WHIRL = WN*>
class WN_TREE_ITER : public WN_TREE_ITER_base<WHIRL>
{
}; // WN_TREE_ITER

// ================================================== ====================
// preorder traversal iterator
// ================================================== ====================
template <typename WHIRL>
class WN_TREE_ITER<PRE_ORDER, WHIRL> : public WN_TREE_ITER_base<WHIRL>
{
public:
WN_TREE_ITER () : WN_TREE_ITER_base<WHIRL> () {}
WN_TREE_ITER (WHIRL wn) : WN_TREE_ITER_base<WHIRL> (wn) {}
void WN_TREE_next (); // next for preorder
}; // WN_TREE_ITER<PRE_ORDER, WHIRL>

template <class WHIRL>
void
WN_TREE_ITER<PRE_ORDER, WHIRL>::WN_TREE_next ()
{
if (_wn == 0) return;
}
--
Regards, Grumble
Jul 23 '05 #1
1 1783
Grumble wrote:
Hello everybody,

(Disclaimer: I do not understand C++ templates.)

I've tried to make a testcase from the original code.

GCC 3.3.5 compiles with no warning, while GCC 3.4.3 rejects it. Could
somebody tell me if it because the code is illegal, and GCC 3.4.3's
stricter parser now rejects it, or is it some kind of regression?

I think the compiler is right. GCC I believe was `fixed' to make
identifiers in templates require dependantcy (if need be). Don't know
for sure but I recall `fixing' a number of these...
template <class WHIRL>
void
WN_TREE_ITER<PRE_ORDER, WHIRL>::WN_TREE_next ()
{
if (_wn == 0) return;
if (this->_wn == 0) return;
}

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
0
by: Felix Finch | last post by:
I have a perl test program which has about 80 test cases, each of which creates its own schema so I can remove them with DROP SCHEMA xxx CASCADE. Normally each test case creates and drops the same...
2
by: Gabrielle A. Grün | last post by:
Hi All, Does anyone know a way around the illegal reference of a non-static member? Thanks. iNHERITANCE HIERACY
6
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp...
8
by: LuB | last post by:
Is this somehow illegal? template<typename T> class A { public: private:
1
by: Manish | last post by:
The code is as ... $folderlistfile = $path."xmlfile.xml"; /* <list> <details id="2"> <name>Books</name>
16
by: DBC User | last post by:
Hi, I have a small XML file, I uploaded to a web page. I have the following code to convert the content I downloaded from web to xml and is giving "Illegal characters in path", but when I try to...
3
by: Tarik Monem | last post by:
Hi Everyone, Still a newbie with FLEX, and I've passed arrays using AJAX to FLEX before, but I've never passed links to FLEX. Basically, this is the OUTPUT, which I wanted, but I'm given an...
8
by: Just another C hacker | last post by:
Hello friends, I'm writing a program in C with some bits in inline asm for efficiency. I'd like to be able to handle illegal instructions from within asm. Here's an example of a standalone asm...
2
by: Kamaria | last post by:
I wrote this program to calculate the income tax of a user depending on whether or not they were married: import javax.swing.JOptionPane; public class Income_Tax { public static void main...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.