473,946 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fun with error messages

One think I really dislike about the (default?) behavior of gcc is the way
it prints errors to console. This is one such report:

cd /home/hattons/code/c++/sth/vmath/test/ # -*-compilation-*-
Entering directory `/home/hattons/code/c++/sth/vmath/test/'
g++ -o testMatrix3 testMatrix3.cc -I/home/hattons/code/c++
In file included from Matrix3Test.hh: 4,
from testMatrix3.cc: 1:
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: prototype for `const
sth::vmath::Ind exedReference<T , sth::vmath::Mat rix3<T>::ORDER> &
sth::vmath::Mat rix3<T>::operat or[](const unsigned int&) const' does not
match any in class `sth::vmath::Ma trix3<T>'
/home/hattons/code/c++/sth/vmath/Matrix3.hh:96: error: candidate is: const
sth::vmath::Ind exedReference<T , sth::vmath::Mat rix3<T>::ORDER> &
sth::vmath::Mat rix3<T>::operat or[](const unsigned int&) const
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: template definition
of
non-template `const sth::vmath::Ind exedReference<T ,
sth::vmath::Mat rix3<T>::ORDER> & sth::vmath::Mat rix3<T>::operat or[](const
unsigned int&) const'

Compilation exited abnormally with code 1 at Fri Oct 8 19:32:56

Now for the fun part. Read the message closely. What it boils down to is
this:

The first line is wrong. You should have used the second line:
IndexedReferenc e<T, Matrix3<T>::ORD ER>& Matrix3<T>::ope rator[](int&)
IndexedReferenc e<T, Matrix3<T>::ORD ER>& Matrix3<T>::ope rator[](int&)

Now here's what the problem was. I have a static const unsigned ORDER = 3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if I
try to use an enum. And I did qualify it where I used it outside the class
definition.

Anybody want to try and explain /that/?

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #1
7 1680
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote in message
news:zu******** ************@sp eakeasy.net...
One think I really dislike about the (default?) behavior of gcc is the way
it prints errors to console. This is one such report:

cd /home/hattons/code/c++/sth/vmath/test/ # -*-compilation-*-
Entering directory `/home/hattons/code/c++/sth/vmath/test/'
g++ -o testMatrix3 testMatrix3.cc -I/home/hattons/code/c++
In file included from Matrix3Test.hh: 4,
from testMatrix3.cc: 1:
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: prototype for `const sth::vmath::Ind exedReference<T , sth::vmath::Mat rix3<T>::ORDER> &
sth::vmath::Mat rix3<T>::operat or[](const unsigned int&) const' does not
match any in class `sth::vmath::Ma trix3<T>'
/home/hattons/code/c++/sth/vmath/Matrix3.hh:96: error: candidate is: const
sth::vmath::Ind exedReference<T , sth::vmath::Mat rix3<T>::ORDER> &
sth::vmath::Mat rix3<T>::operat or[](const unsigned int&) const
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: template definition of
non-template `const sth::vmath::Ind exedReference<T ,
sth::vmath::Mat rix3<T>::ORDER> & sth::vmath::Mat rix3<T>::operat or[](const unsigned int&) const'

Compilation exited abnormally with code 1 at Fri Oct 8 19:32:56

Now for the fun part. Read the message closely. What it boils down to is
this:

The first line is wrong. You should have used the second line:
IndexedReferenc e<T, Matrix3<T>::ORD ER>& Matrix3<T>::ope rator[](int&)
IndexedReferenc e<T, Matrix3<T>::ORD ER>& Matrix3<T>::ope rator[](int&)

Now here's what the problem was. I have a static const unsigned ORDER = 3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if I
try to use an enum. And I did qualify it where I used it outside the class definition.

Anybody want to try and explain /that/?


Not here. Here we discuss the language, not the operation
or idiosyncracies of any particular implementation, nor the
deciphering of diagnostic messages. The language does not
mandate any particular form for diagnostic messages, only
that 'a diagnostic' be issued upon encountering certain language
violations. E.g. if you supply the wrong number of arguments to
a function, it's valid for a compiler to complain: "your dog
has fleas". If you're unhappy with the behavior of a compiler
your recourses are to complain to the vendor, or use (or create)
something else.

I have many times seen folks deride a compiler (or other piece
of software), but none has ever claimed to be able to create
anything superior (I've taken to calling this the "Microsoft
Windows Syndrome". There, I feel better now. :-)

I think you've been reading and posting here long enough to realize
that your message is not topical here. If you want to pursue this,
please take it to a gcc group or mailing list.

www.gcc.gnu.org
-Mike
Jul 22 '05 #2
Mike Wahler wrote:
I think you've been reading and posting here long enough to realize
that your message is not topical here. If you want to pursue this,
please take it to a gcc group or mailing list.

www.gcc.gnu.org
-Mike


Why don't you address the part that /is/ about the language rather than
trying to play c.l.c++ policeman? Here it is again for your convenience:

Now here's what the problem was.**I*have*a* static*const*un signed*ORDER*=* 3
in Matrix3<T>.**Wh en*I*try*to*use *that*as*a*temp late*parameter* in*the
definition of a member function the compiler gets confused.**Like wise*if*I
try to use an enum.**And*I*di d*qualify*it*wh ere*I*used*it*o utside*the*clas s
definition.

Anybody want to try and explain /that/?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #3
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote...
[...]
Now here's what the problem was. I have a static const unsigned ORDER = 3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if I
try to use an enum. And I did qualify it where I used it outside the class
definition.

Anybody want to try and explain /that/?


Can you use C++ to show the problem instead of trying to explain
in English? Many of us here understand C++ better than English,
you know.

So:

#include <iostream>

namespace sth {
namespace vmath {
template<class T> class Matrix3 {
static const unsigned ORDER = 3;
public:
template<unsign ed N> void foo();
};

template<class T> template <unsigned N>
void Matrix3<T>::foo () {
// who cares
for (int i = 0; i < ORDER; ++i)
std::cout << "beep!";
}
}
}

int main() {
sth::vmath::Mat rix3<double> m;
m.foo<2>();
}

Is that something you have a problem with? Comeau compiles it fine.
G++ v 3.2.2 does just as well. If that's not it, how about reading
the FAQ for a change? 5.8 should be right about what you need.

V
Jul 22 '05 #4
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote...
[...]
Now here's what the problem was. I have a static const unsigned ORDER = 3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if I
try to use an enum. And I did qualify it where I used it outside the
class definition.

Anybody want to try and explain /that/?


Can you use C++ to show the problem instead of trying to explain
in English? Many of us here understand C++ better than English,
you know.


#include <iostream>
//#define BROKEN
#ifndef BROKEN

#define REDRO 3
#define REDRO2 REDRO

#else

#define REDRO ORDER
#define REDRO2 C<T>::ORDER

#endif

namespace sth{
template <typename T, unsigned N>
struct S
{
S():n(N){}
T n;
std::ostream& print(std::ostr eam& out) const
{
return out << "The value of n is:" << n << "\n";
}
};

template<typena me T>
class C {
public:
static const unsigned ORDER=3;

const S<T, REDRO>& gimmie_s() const;

protected:
S<T, REDRO> _s;

};

template <typename T>
const S<T, REDRO2>& C<T>::gimmie_s( ) const
{
return _s;
}
}
int main()
{
sth::C<float> c;
c.gimmie_s().pr int(std::cout);
}

--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #5
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote...
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote...
[...]
Now here's what the problem was. I have a static const unsigned ORDER =
3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if
I
try to use an enum. And I did qualify it where I used it outside the
class definition.

Anybody want to try and explain /that/?


Can you use C++ to show the problem instead of trying to explain
in English? Many of us here understand C++ better than English,
you know.


#include <iostream>
//#define BROKEN
#ifndef BROKEN

#define REDRO 3
#define REDRO2 REDRO

#else

#define REDRO ORDER
#define REDRO2 C<T>::ORDER

#endif

namespace sth{
template <typename T, unsigned N>
struct S
{
S():n(N){}
T n;
std::ostream& print(std::ostr eam& out) const
{
return out << "The value of n is:" << n << "\n";
}
};

template<typena me T>
class C {
public:
static const unsigned ORDER=3;

const S<T, REDRO>& gimmie_s() const;

protected:
S<T, REDRO> _s;

};

template <typename T>
const S<T, REDRO2>& C<T>::gimmie_s( ) const
{
return _s;
}
}
int main()
{
sth::C<float> c;
c.gimmie_s().pr int(std::cout);
}


OK, when 'BROKEN' is defined, the program compiles with Comeau (online
trial) but doesn't with some other compilers, I take it. MIPSpro gets
it right too, BTW.

So, ultimately your problem is with G++, and your beef with Mike was
unfounded. Post to gnu.g++.help

Victor
Jul 22 '05 #6
Victor Bazarov wrote:


OK, when 'BROKEN' is defined, the program compiles with Comeau (online
trial) but doesn't with some other compilers, I take it. MIPSpro gets
it right too, BTW.

So, ultimately your problem is with G++, and your beef with Mike was
unfounded. Post to gnu.g++.help

Victor


The last time that argument was given, I ended up sending mail the Bjarne
Stroustrup telling him about the problem with his code.
http://gcc.gnu.org/ml/gcc/2004-04/msg01268.html
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell

Jul 22 '05 #7
"Steven T. Hatton" <su******@setid ava.kushan.aa> wrote...
Victor Bazarov wrote:


OK, when 'BROKEN' is defined, the program compiles with Comeau (online
trial) but doesn't with some other compilers, I take it. MIPSpro gets
it right too, BTW.

So, ultimately your problem is with G++, and your beef with Mike was
unfounded. Post to gnu.g++.help

Victor


The last time that argument was given, I ended up sending mail the Bjarne
Stroustrup telling him about the problem with his code.


What kind of "argument" are you looking for? The code is supposed to
compile. And it does with at least two compilers I've tried. What else?
Was that code from a book or something? What? If you want to get to
the bottom of it, you will have to give more information. If you want
to play games, count me out.

V
Jul 22 '05 #8

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

Similar topics

2
1924
by: lkrubner | last post by:
This is a general computer question, but I'm writing in PHP so I'll post this to comp.lang.php. I've been writing a content management system. I've a Singleton object that keeps track of all errors and stores them in an array. As things work right now, I write out each error message individually. I'm thinking that as the code grows, this system will not continue to scale. Right now my software consists of 1.4 megs of PHP code. I don't...
5
10410
by: Steve | last post by:
Hi; I went to the microsoft site to try to find a guide to the error messages that the jdbc drivers give ( for sqlserver 2000 ). I had no luck. Does anyone know if there is such a guide? I got this mysterious error message below in my logs ( nothing visible
10
5825
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address, city, state, etc. When the user wants to search for a particular record, he does two things: 1. On the form is a text box on which he enters the text he is searching for.
10
2740
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through VS, however, when I change to release and put it out on the web it fails giving me the following error message The underlying connection was closed. Could not establish a trust relationship with the remote server.
0
2703
by: Janning Vygen | last post by:
Hi, i have a question about how to handle postgresql constraint errors in the client app. I found some mails in the archive about it, too. But i have still so many questions about how to do it, where to check it and how to display a good error message. I would love to hear some comments about my ideas:
8
9598
by: Brian Tkatch | last post by:
Server: DB2/SUN 8.1.6 Client: DB2 Connect Personal Edition (No 11) <URL:ftp://ftp.software.ibm.com/ps/products/db2/fixes2/english-us/db2winIA32v8/fixpak/FP11_WR21365/FP11_WR21365_CONPE.exe> Uninstalled old version, installed new version, and am now trying to use the CLP. <<<<<<<<<<<< For more detailed help, refer to the Online Reference Manual.
16
2652
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting language. The idea, apparently, is that the PHP interpreter writes all the error messages that are...
2
19524
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
2
1888
by: FutureShock | last post by:
I am using a registration class to process a registration form and need some opinions on returning error messages. I am self referring the page on submit. I would like to send each form field to the class for processing (validating, sanitizing, etc..) So far no problem. Now I am throwing ideas around on how best to check for error messages to the users.
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
10149
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
11320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10679
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6317
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4928
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3524
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.