473,480 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Segfault on new?

Okay, I have a really simple program that illustrates a problem I'm
having.

I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
Is my installation just gone out the window, or am I so incredibly
tired that I can't even do a dynamic allocation anymore?
Sep 30 '08 #1
6 2410
Scoots wrote:
Okay, I have a really simple program that illustrates a problem I'm
having.

I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
Is my installation just gone out the window, or am I so incredibly
tired that I can't even do a dynamic allocation anymore?
The code seems OK (the memory leak is beside the point, I guess). If
you need your question answered with VC++ in mind, then you need to ask
it in the VC++ newsgroup, though: microsoft.public.vc.language.

There can be some compiler specific settings that are off-topic here,
try the other newsgroup and see what they say...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 30 '08 #2


On Sep 30, 5:54 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
Scoots wrote:
Okay, I have a really simple program that illustrates a problem I'm
having.
I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
Is my installation just gone out the window, or am I so incredibly
tired that I can't even do a dynamic allocation anymore?

The code seems OK (the memory leak is beside the point, I guess). If
you need your question answered with VC++ in mind, then you need to ask
it in the VC++ newsgroup, though: microsoft.public.vc.language.

There can be some compiler specific settings that are off-topic here,
try the other newsgroup and see what they say...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide quoted text -

- Show quoted text -
Well, the memory leak is kinda irrelevant, I just commented out the
few hundred other lines in the code and didn't bother posting them
here. There IS a delete[], it's just commented out.

And I didn't think this was a VC++ question in particular, since I'm
not using a single call to anything relating to VC++. What I posted
should be standard c++ in it's entirety.

My question, is what can be causing that. And I believe your answer
was: "Compiler."

Thanks,
~Scoots.

(P.S. I appologize for any seeming rudeness, it is unintentional.)
Sep 30 '08 #3
Scoots wrote:
>

On Sep 30, 5:54 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
>Scoots wrote:
Okay, I have a really simple program that illustrates a problem I'm
having.
I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
Is my installation just gone out the window, or am I so incredibly
tired that I can't even do a dynamic allocation anymore?

The code seems OK (the memory leak is beside the point, I guess). If
you need your question answered with VC++ in mind, then you need to ask
it in the VC++ newsgroup, though: microsoft.public.vc.language.

There can be some compiler specific settings that are off-topic here,
try the other newsgroup and see what they say...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide quoted
text -

- Show quoted text -

Well, the memory leak is kinda irrelevant, I just commented out the
few hundred other lines in the code and didn't bother posting them
here. There IS a delete[], it's just commented out.

And I didn't think this was a VC++ question in particular, since I'm
not using a single call to anything relating to VC++. What I posted
should be standard c++ in it's entirety.

My question, is what can be causing that. And I believe your answer
was: "Compiler."

Thanks,
~Scoots.

(P.S. I appologize for any seeming rudeness, it is unintentional.)
I don't use arrays much, so the syntax is a bit unfamiliar to me. However,
its working fine here with gcc version 4.3.1 on OpenSUSE 11.0

int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; //Â* <<--Segfaults. Â* ??????
hey[0] = 99;
cout << "hey = " << hey << " hey[0] = " << hey[0] << endl;
return 0;
}

Output: hey = 0x804b008 hey[0] = 99

Chris Gordon-Smith
www.simsoup.info


Sep 30 '08 #4
Scoots <li*********@msn.comkirjutas:
Okay, I have a really simple program that illustrates a problem I'm
having.

I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
With VC++ you should not be able to get a segfault. At best you could hope
for an access violation ;-)

This aside, your code looks fine. Are you sure you posted the actual code?

Paavo
Oct 1 '08 #5
Scoots wrote:
On Sep 30, 5:54 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
>Scoots wrote:
Okay, I have a really simple program that illustrates a problem I'm
having.
I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
this problem:
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
return 0;
}
Is my installation just gone out the window, or am I so incredibly
tired that I can't even do a dynamic allocation anymore?

The code seems OK (the memory leak is beside the point, I guess). If
you need your question answered with VC++ in mind, then you need to ask
it in the VC++ newsgroup, though: microsoft.public.vc.language.

There can be some compiler specific settings that are off-topic here,
try the other newsgroup and see what they say...

Well, the memory leak is kinda irrelevant, I just commented out the
few hundred other lines in the code and didn't bother posting them
here. There IS a delete[], it's just commented out.

And I didn't think this was a VC++ question in particular, since I'm not
using a single call to anything relating to VC++.

Your question wasn't specific to VC++. It was fine, but cannot be answered
here.
What I posted should be standard c++ in it's entirety.
Yes, it is.
My question, is what can be causing that. And I believe your answer
was: "Compiler."
Yes. Regarding standard C++, your code is - as far as I can see - correct,
so it must be some compiler issue. And for that, a VC++ group will be more
appropriate.

Oct 1 '08 #6
Indeed, this was the code, minus a few thousand lines that were
essentially commented out (the calls to other files/functions) which
is why I took out the includes. But I had yes, actually reduced my
main to that through commenting out code.

And yes, it wasn't a true segfault :-)

Too many years in school to take segfault out of my vocabulary though!

I took your advice and asked over there and the issue has been...
well, avoided if not resolved.
Oct 3 '08 #7

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

Similar topics

12
3132
by: Nathaniel Echols | last post by:
I've written a function in C to perform protein sequence alignment. This works fine in a standalone C program. I've added the necessary packaging to use it in Python; it returns three strings and...
6
2998
by: Juho Saarikko | last post by:
The program attached to this message makes the Python interpreter segfault randomly. I have tried both Python 2.2 which came with Debian Stable, and self-compiled Python 2.3.3 (newest I could find...
6
1964
by: Stefan Behnel | last post by:
Hi! In Python 2.4b3, the deque is causing a segfault on two different machines I tested on. With deque, my program runs fine for a while (at least some tens of seconds up to minutes) and then...
0
1809
by: dale | last post by:
Python newbie disclaimer on I am running an app with Tkinter screen in one thread and command-line input in another thread using raw_input(). First question - is this legal, should it run...
10
2875
by: Arthur J. O'Dwyer | last post by:
I'm seeing a bug at the moment that I can't track down. It's part of a moderately large program, but here is a small program that exhibits the bug on gcc. (The program code follows at the bottom...
4
1868
by: Jim Strathmeyer | last post by:
Under what circumstances would closing a istream object (such as 'in.close()') SEGFAULT?
4
3482
by: William Payne | last post by:
Hello, I was under the impression that if I made a class Foo and if I didn't specify a copy constructor I would get one anyway that simply assigns the member variables (and that won't work for...
10
1917
by: name | last post by:
When I started testing the algorithms for my wrap program, I threw together this snippet of code, which works quite well. Except that it (predictably) segfaults at the end when it tries to go...
3
2287
by: kj | last post by:
I am trying to diagnose a bug in my code, but I can't understand what's going on. I've narrowed things down to this: I have a function, say foo, whose signature looks something like: int foo(...
14
4934
by: Donn Ingle | last post by:
Yo, An app of mine relies on PIL. When PIL hits a certain problem font (for unknown reasons as of now) it tends to segfault and no amount of try/except will keep my wxPython app alive. My first...
0
7037
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,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
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...
1
6732
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...
0
6886
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...
0
2990
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...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.