Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by Brendan Kehoe
Wed, 27 Jan 1993 03:25
[djb@babypuss.mitre.org : ]
Author: Brendan Kehoe
Date: Wed, 27 Jan 1993 03:25
Date: Wed, 27 Jan 1993 03:25
66 lines
2280 bytes
2280 bytes
------- Start of forwarded message -------
From: djb@babypuss.mitre.org (David J. Braunegg)
To: bug-g++@prep.ai.mit.edu
Cc: djb@babypuss.mitre.org
Date: Fri, 22 Jan 93 17:29:04 -0500
This is a bug report for g++ (gcc) version 2.3.3, running on a Sun
Sparcstation, OS 4.1.
Your declaration of
ostream& operator<<(void *p);
in iostream.h is in error. Unless you have truly defined operator<<
on void* pointers so that it modifies the pointer, the declaration
should instead be
ostream& operator<<(const void *p);
For example, the following program should *not* issue the const
violation warning that it does.
#include <iostream.h>
int main()
{
const char *foo = "stuff";
cout << (const void *)foo << endl;
return 0;
}
djb@bambam>g++ -g -Wall test.cc
test.cc: In function `int main ()':
test.cc:7: warning: argument passing of non-`const *' pointer from `const *'
test.cc:7: warning: argument passing of non-`const *' pointer from `const *'
I have encountered this warning frequently, because in my code I am
often writing out the address of an object to help identify it. If
foo is `const <class> *', then I must cast it to `const void *' and
*not* to `void *' when printing its address in order to avoid a const
violation.
Please contact me if you have any further questions.
Dave
------- End of forwarded message -------
--
Brendan Kehoe brendan@cygnus.com
Cygnus Support, Mountain View, CA +1 415 903 1400
``In a cruel and imperfect world,'' says critic Rex Reed,
``[Audrey Hepburn] was living proof that God could still create perfection.''
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads