472,955 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Some strange error

I took old code and decided to modify it a bit, and I just noticed
that it does not compile at all and before server one of severs (main)
crashed in the system it was working fine (I am really sure that I
remember that).

Now I am getting this error:
[me@smth kazkas]$ make
g++ -Wall -ansi -pedantic -c pirma_lib.cpp
g++ -Wall -ansi -pedantic -c pirma.cpp
In file included from pirma.cpp:2:
pirma_lib.h:13: syntax error before `('
pirma.cpp: In function `int main(int, const char **)':
pirma.cpp:68: no matching function for call to `Aibe::toString ()'
pirma.cpp:126: no matching function for call to `Aibe::toString ()'
*** Error code 1

Stop in /somewhere.

The main problem should be right here:
pirma_lib.h:13: syntax error before `('

So here it is:
#ifndef PIRMA_LIB
#define PIRMA_LIB

class Aibe {
public:
Aibe();
Aibe(int arr[], int length);
Aibe(int item, ...);
~Aibe();

bool isSubSet(const Aibe &other) const;
void toArray(int **arr) const;
std::string toString() const; //
<--------------
int length() const;
//void Sort();

Any ideas why I can not compile it anymore? Could something be wrong
with std?
Jun 27 '08 #1
19 1696
david wrote:
I took old code and decided to modify it a bit, and I just noticed
that it does not compile at all and before server one of severs (main)
crashed in the system it was working fine (I am really sure that I
remember that).

Now I am getting this error:
[me@smth kazkas]$ make
g++ -Wall -ansi -pedantic -c pirma_lib.cpp
g++ -Wall -ansi -pedantic -c pirma.cpp
In file included from pirma.cpp:2:
pirma_lib.h:13: syntax error before `('
pirma.cpp: In function `int main(int, const char **)':
pirma.cpp:68: no matching function for call to `Aibe::toString ()'
pirma.cpp:126: no matching function for call to `Aibe::toString ()'
*** Error code 1

Stop in /somewhere.

The main problem should be right here:
pirma_lib.h:13: syntax error before `('

So here it is:
#ifndef PIRMA_LIB
#define PIRMA_LIB

class Aibe {
public:
Aibe();
Aibe(int arr[], int length);
Aibe(int item, ...);
~Aibe();

bool isSubSet(const Aibe &other) const;
void toArray(int **arr) const;
std::string toString() const; //
<--------------
int length() const;
//void Sort();

Any ideas why I can not compile it anymore? Could something be wrong
with std?
#include <string>

--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #2
No, string.h has nothing to do in this situation and I am not using
any C style strings.
And I just tested the same code on my MacBook and it did work
perfectly.
While on server (FreeBSD 4.11-RELEASE-p11) with 2.95.4 it does not
work anymore...
Jun 27 '08 #3
david wrote:
No, string.h has nothing to do in this situation and I am not using
any C style strings.
And I just tested the same code on my MacBook and it did work
perfectly.
While on server (FreeBSD 4.11-RELEASE-p11) with 2.95.4 it does not
work anymore...
In the code you provided you have the line:

std::string toString() const;

I did not see
#include <string>
in the code you provided. When you add
#include <string>
to the top of that header and compile do you still get the error?

And I did not say string.h but <string <stringis std::string, which you
are using in this code. string.h is c-style strings.


--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #4
Yes, not it did compile but I am getting some error on run time.
Jun 27 '08 #5
Now I always gettting a lot of lines:
pirma in free(): warning: chunk is already free
Even after commenting the whole destructor, which uses free...
Something strange... It did work very fine before...
Jun 27 '08 #6
david wrote:
Now I always gettting a lot of lines:
pirma in free(): warning: chunk is already free
Even after commenting the whole destructor, which uses free...
Something strange... It did work very fine before...
Who or what are you replying to? This does not make sense.

--
Ian Collins.
Jun 27 '08 #7
Ian Collins wrote:
david wrote:
>Now I always gettting a lot of lines:
pirma in free(): warning: chunk is already free
Even after commenting the whole destructor, which uses free...
Something strange... It did work very fine before...

Who or what are you replying to? This does not make sense.
he is replying to me. He is stating that with
#include <string>
his code now compiles, but produces run time error.

David, you have not shown enough code for us to determine where this run
time error would be coming from. You either need to show more code, or use
a debugger.

--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #8
It's still very strange... Tested the same code again inside on one of
the Linux machine (Debian) and code compiled very nicely, zero errors/
warning and etc, no run time errors.

Doing the same on FreeBSD machine it produces run time error, program
is compiled into "pirma", and after execution it works as it should be
and after some time it throws multiple lines of "pirma in free():
warning: chunk is already free" and some parts of program works
completely wrong.

And I don't use free() in any part of code. I still think that
compiler/some libraries in this machine might be broken and the error
could be produced no in my code. The code is too simply and it runs on
other machines.
Jun 27 '08 #9
david wrote:
It's still very strange... Tested the same code again inside on one of
the Linux machine (Debian) and code compiled very nicely, zero errors/
warning and etc, no run time errors.
What code?

--
Ian Collins.
Jun 27 '08 #10
david wrote:
It's still very strange... Tested the same code again inside on one of
the Linux machine (Debian) and code compiled very nicely, zero errors/
warning and etc, no run time errors.

Doing the same on FreeBSD machine it produces run time error, program
is compiled into "pirma", and after execution it works as it should be
and after some time it throws multiple lines of "pirma in free():
warning: chunk is already free" and some parts of program works
completely wrong.

And I don't use free() in any part of code. I still think that
compiler/some libraries in this machine might be broken and the error
could be produced no in my code. The code is too simply and it runs on
other machines.
You are probably running into undefined behavior. Undefined behavior means
that the standard doesn't define what will happen in some situations. For
example: the following is undefined behavior:

char* foo;
delete foo;

foo wasn't initilialized, it could point to anything. It might point to
address 0 so would be a null pointer, or some compilers might point it to
some random spot in memory or.. anywhere. So the delete foo could do
differnet things on differnet compilers. It's undefined.

So your code could have undefined behavior that works one way on Debian, one
way on FreeBSD. I would suggest you create the smallest compilable program
that will produces this behavior on FreeBSD and post here it.


--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #11
I will try that a bit later, one more thing I am using the same exact
version of compiler and I get those run time errors only on that
machine and it even did work before. So even "undefined behavior" here
sound very strange, because that would depend on the compiler which is
the same.
Jun 27 '08 #12
Found which part of code throw that warning:
void Aibe::innerDestructor(Aibe &other) {
child *tmp;
while (other.root != NULL)
{
tmp = other.root;
other.root = tmp->next;
delete(tmp); // <- THIS LINE
}
other.root = NULL;
other.size = 0;
}
Jun 27 '08 #13
david wrote:
Found which part of code throw that warning:
void Aibe::innerDestructor(Aibe &other) {
child *tmp;
while (other.root != NULL)
{
tmp = other.root;
other.root = tmp->next;
delete(tmp); // <- THIS LINE
}
other.root = NULL;
other.size = 0;
}
Okay, this looks like a recursive destructor, but it depends on child's
destructor. I'm guessing that child's destructor also deletes .root or some
some deleting.

Can you post child's destructor here please?

--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #14
Here is the info:
http://www.paste.lt/paste/3ca55040e2...e8c0ce6067d6e5

And this is the only destructor which frees the list from the heap.
When I was making this test I commented the line where InnerDestructor
is called (not a good idea) and as you can see it still produces this
mess. I even set up BSD in one of my machines at home, running g++
3.4.6 which does not have any problems. Looks like this only effects
old versions of compilers.

I still can't get this:
>Starting to delete (0xbfbff8d8)
Deleted item: 1
Deleted item: 2
Deleted item: 3
Deleted item: 4
Deleted item: 5
Deleted item: 6
Deleted item: 7
Starting to delete (0xbfbff954)
Deleted item: 1
ccc + ddd : 1

First of all it launches destructor of the ddd which has 7 elements
(1,2,..,7) inside and when one more for I don't know there is no
instance of that class with only one element. So ddd becomes empty and
ccc has 1 element (but had five elements) and {1} + {} = {1}; Why does
it call destructor when no one asks to do that? Was that how it was
designed few years ago?
Jun 27 '08 #15
Found something even more interesting:

Some time spent with a debugger and searching for reports of similar
error messages (and drawing on my own experience developing
software :-)
leads me to feel that the junk pointer error message is a symptom of
library ABI incompatibility. First of all, the message is from the
system
call to free in libc; this is not a Qt problem. Since libc was built
using the compiler provided by the system (FreeBSD 4.cool it uses the
gcc
2.95.4 ABI. However, I have upgraded to gcc 3.3.1 for my development
work. The ABI went through significant changes across this major rev.
I've had to recompile several libraries to overcome the differences.
So even
though this problem does not always occur (I have not dug deep enough
to
identify the specific cause for free getting upset), and does not
occur
with the other C++ libraries I have developed, I now think that the
system libraries (including the X11 libraries) need to be brought
across
the ABI divide.

And here:
http://osdir.com/ml/hardware.gps.gps.../msg00000.html
Jun 27 '08 #16
david wrote:
Found something even more interesting:

Some time spent with a debugger and searching for reports of similar
error messages (and drawing on my own experience developing
software :-)
leads me to feel that the junk pointer error message is a symptom of
library ABI incompatibility.
Your code has a number of memory related nasties, which were too
involved for a casual scan. Run your code under whatever memory access
checker your platform provides and you will find them.

--
Ian Collins.
Jun 27 '08 #17
Ian Collins wrote:
david wrote:
>Found something even more interesting:

Some time spent with a debugger and searching for reports of similar
error messages (and drawing on my own experience developing
software :-)
leads me to feel that the junk pointer error message is a symptom of
library ABI incompatibility.

Your code has a number of memory related nasties, which were too
involved for a casual scan. Run your code under whatever memory
access checker your platform provides and you will find them.
Someone has suggested valgrind. I've never used it myelf, but it seems to
be opensource. I would suggest you go to http://valgrind.org/ and download
it and give it a try. Maybe it'll help.

--
Jim Langston
ta*******@rocketmail.com
Jun 27 '08 #18
I my case it should not, in assignment operator not. First of all I
free all elements from the left side variable (maybe it would better
to call it lvalue?) and then make exact copy of the right variable.
Basically it works as a copy constructor.
Jun 27 '08 #19
On May 2, 12:48 pm, david <David.Abdurachma...@gmail.comwrote:
I my case it should not, in assignment operator not. First of all I
free all elements from the left side variable (maybe it would better
to call it lvalue?) and then make exact copy of the right variable.
Basically it works as a copy constructor.
I'm not sure what you're responding to (that "should not"), but
your suggestion as to how to implement an assignment operator
won't work. Think of what will happen if something in the copy
throws.

For classes with pointers to dynamically allocated data, the
swap idiom is simple, and almost always appropriate; if the
class has more than one such pointer, it's really the way to go,
no questions asked. Whatever you do, however, it's generally a
good idea to do anything which can possibly throw before
modifying any member variables; failing that, at least make sure
that calling the destructor will never result in undefined
behavior.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #20

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

Similar topics

0
by: Andreas.Bretl | last post by:
Hi all, We are currently facing a strange problem. We wrote an ASP application using some sessions and database-connectivity, nothing special. On some machines (we are all using IE5.5 / IE6)...
6
by: Eric Boutin | last post by:
Hi ! I have a strange problem with a std::ostringstream.. code : #include <sstream> /*...*/ std::ostringstream ss(); ss << "\"\"" << libpath << "\"\" \"\"" << argfilename << "\"\"...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
0
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
5
by: Nathan Sokalski | last post by:
When I view my index.aspx page any time after the first time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize)...
0
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
11
by: Mike C# | last post by:
Hi all, I keep getting a strange error and can't pin it down. The message is: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.