Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - mudflap and C++: (4 Items)
   
mudflap and C++  
Using 6.4.1 I started playing around with mudflap.

The following C program:

#include <stdio.h>


int main(void)
{
	int a[10];
	
	a[11] = 64;
	printf("this is a atest %d\n", a[11]);
	return 1;
	
}

Does what I expect it to and mudflap report an error.

I compile this in C++, the program will do an Abort !!!  I chase it down to a exception being throw in a new() executed 
before main(), from ios_base::_Init().

Build with qcc -fmudflap -lmudflap -g2 -osize -fexceptions inthemud.cpp.

Suggestions?

Re: mudflap and C++  
Mario Charest wrote:
> Using 6.4.1 I started playing around with mudflap.
> 
> The following C program:
> 
> #include <stdio.h>
> 
> 
> int main(void)
> {
> 	int a[10];
> 	
> 	a[11] = 64;
> 	printf("this is a atest %d\n", a[11]);
> 	return 1;
> 	
> }
> 
> Does what I expect it to and mudflap report an error.
> 
> I compile this in C++, the program will do an Abort !!!  I chase it down to a exception being throw in a new() 
executed before main(), from ios_base::_Init().
> 
> Build with qcc -fmudflap -lmudflap -g2 -osize -fexceptions inthemud.cpp.
> 
> Suggestions?

Try compiling without -lmudflap:

qcc -fmudflap -lmudflap -g2 -Osize -fexceptions inthemud.cpp


libmudflap needs to be initialized before shared objects 
that call wrapped functions (like malloc), therefore when 
doing "ldd inthemud" it should list it below libcpp.

---
Aleksandar
Re: mudflap and C++  
> 
> qcc -fmudflap -lmudflap -g2 -Osize -fexceptions inthemud.cpp
> 
> 
> libmudflap needs to be initialized before shared objects 
> that call wrapped functions (like malloc), therefore when 
> doing "ldd inthemud" it should list it below libcpp.

I was about to come post about the discovering that on my own ( want my mom to be proud of me ).  I compare the command 
line used by the IDE with mine and figure that was the difference.

Steve are you reading this?  Would make a nice addition to the documentation.

> 
> ---
> Aleksandar


RE: mudflap and C++  
Yes, I saw this. I'll try to find a home for it in the docs. Thanks for
the suggestion.

Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems 
 

> -----Original Message-----
> From: Mario Charest [mailto:community-noreply@qnx.com] 
> Sent: Monday, August 10, 2009 3:45 PM
> To: general-toolchain
> Subject: Re: mudflap and C++
> 
> 
> > 
> > qcc -fmudflap -lmudflap -g2 -Osize -fexceptions inthemud.cpp
> > 
> > 
> > libmudflap needs to be initialized before shared objects 
> > that call wrapped functions (like malloc), therefore when 
> > doing "ldd inthemud" it should list it below libcpp.
> 
> I was about to come post about the discovering that on my own 
> ( want my mom to be proud of me ).  I compare the command 
> line used by the IDE with mine and figure that was the difference.
> 
> Steve are you reading this?  Would make a nice addition to 
> the documentation.
> 
> > 
> > ---
> > Aleksandar
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post35623
> 
>