maximum size of a program

O

Obnoxious User

hello everyone can anyone please tell me is there any limit on the size
of the program you are creating. i mean i tried to declare an 10000 size
long double array and the compilation error says segmentation fault.
please help me .and also is there anyway to find the digital signature
of an image using c++ or some c++ library.

You mean like

long double array[10000];

I think you're doing something more to earn the
segmentation fault.
 
M

mohangupta13

hello everyone can anyone please tell me is there any limit on the
size of the program you are creating.
i mean i tried to declare an 10000 size long double array and the
compilation error says segmentation fault.
please help me .and also is there anyway to find the digital signature
of an image using c++ or some c++ library.

thank you
mohan gupta
 
A

Andy Champ

hello everyone can anyone please tell me is there any limit on the
size of the program you are creating.
i mean i tried to declare an 10000 size long double array and the
compilation error says segmentation fault.
please help me .and also is there anyway to find the digital signature
of an image using c++ or some c++ library.

thank you
mohan gupta

This isn't an inherent C++ problem, but a system dependent one.

A double is going to be at least 4 bytes, and may be up to 10. If
you're on a 16 bit architecture (64Kb memory size) that won't fit. On
any 32 bit one I know about, it won't be a problem.

Strictly speaking, this is OT, and you should go to a group which is
specific to your system but if you post back details of the system and
the code that produces the problem you'll probably get help.

Andy
 
R

Rolf Magnus

hello everyone can anyone please tell me is there any limit on the
size of the program you are creating.

Yes, but that is very system and compiler dependant.

i mean i tried to declare an 10000 size long double array and the

How exactly?
compilation error says segmentation fault.

Are you sure that you got the segfalut during _compiling_? If that's the
case, it's a compiler bug, since the compiler itself shouldn't crash.
please help me .and also is there anyway to find the digital signature
of an image using c++ or some c++ library.

I don't known what you mean by "digital signature of an image", but I'd say
the C++ standard library doesn't offer it.
 
E

Erik Wikström

hello everyone can anyone please tell me is there any limit on the
size of the program you are creating.

There isn't really a limit on the size but on a modern 32-bit
architecture you only have 2-3 GB virtual memory to play with. An array
of 10000 doubles doesn't even take 1 MB so that should not be a problem.
i mean i tried to declare an 10000 size long double array and the
compilation error says segmentation fault.

If that is the compilation error that would mean that the compiler
crashed, are you sure it is not a run-time error? The most likely cause
of a segfault is that while accessing the array you are accessing an
element outside of the array. Please also note that it might be better
to use std::vector instead of using a raw array.
 
I

Ivan Vecerina

: hello everyone can anyone please tell me is there any limit on the
: size of the program you are creating.
: i mean i tried to declare an 10000 size long double array and the
: compilation error says segmentation fault.

Size limits are platform specific (need to check documentation of
your compiler / computer).
However:

If it is images that you are processing, you should not be
declaring a fixed-size array. You need to use dynamic memory
allocation, probably std::vector or another type of image class.

: please help me .and also is there anyway to find the digital signature
: of an image using c++ or some c++ library.

There are many different ways to compute a digital signature
(general ways will only match identical images, some allow
some can rate similarity, some will "hide" a custom signature
within the data of the image).
This forum, focused on the C++ language, is probably not the
best place to ask ( see maybe comp.graphics.algorithms ... ).
 
J

James Kanze

hello everyone can anyone please tell me is there any limit on the
size of the program you are creating.

It's unspecified, but unless you're compiling on a system with
infinite memory, there's bound to be some limit.
i mean i tried to declare an 10000 size long double array and
the compilation error says segmentation fault.

The compiler segfaulted with something that small. Sounds like
a pretty poor implementation to me.

I have some machine generated C++ of a couple of million lines,
and the compiler (g++) outputs an error message to the effect
that it is out of memory.
please help me .and also is there anyway to find the digital
signature of an image using c++ or some c++ library.

I'm not sure if it's what you mean, but there are several
libraries solutions for calculating different types of digital
signatures. (My own supports MD 5 and all of the SHA
signatures.)
 
J

James Kanze

: hello everyone can anyone please tell me is there any limit on the
: size of the program you are creating.
: i mean i tried to declare an 10000 size long double array and the
: compilation error says segmentation fault.
Size limits are platform specific (need to check documentation
of your compiler / computer).

I don't think the compiler is required to document them, and
quite frankly, I don't see how it could. (Typically, the limits
will depend on the amount of virtual memory available, which
varies from one machine to the other, and in time on a given
machine. And how much memory the compiler requires will depend
on context as well: you might be able to declare 200,000
variables with four letter names, but only 150,000 with twenty
letter names.)
 
I

Ivan Vecerina

:On 21 mar, 13:25, "Ivan Vecerina" wrote:
:>
:> : hello everyone can anyone please tell me is there any limit on the
:> : size of the program you are creating.
:> : i mean i tried to declare an 10000 size long double array and the
:> : compilation error says segmentation fault.
:
:> Size limits are platform specific (need to check documentation
:> of your compiler / computer).
:
:I don't think the compiler is required to document them, and
:quite frankly, I don't see how it could.

James,
See the informative Annex B of the C++ standard, paragraph 1:

<< Because computers are finite, C++ implementations are
inevitably limited in the size of the programs they can
successfully process. Every implementation shall document
those limitations where known. This documentation may cite
fixed limits where they exist, say how to compute variable
limits as a function of available resources, or say that
fixed limits do not exist or are unknown. >>


Salutations / Gruessen,
Ivan
 
P

Pete Becker

:On 21 mar, 13:25, "Ivan Vecerina" wrote:
:>
:> : hello everyone can anyone please tell me is there any limit on the
:> : size of the program you are creating.
:> : i mean i tried to declare an 10000 size long double array and the
:> : compilation error says segmentation fault.
:
:> Size limits are platform specific (need to check documentation
:> of your compiler / computer).
:
:I don't think the compiler is required to document them, and
:quite frankly, I don't see how it could.

James,
See the informative Annex B of the C++ standard, paragraph 1:

"Informative" means that it does not impose requirements.
<< Because computers are finite, C++ implementations are
inevitably limited in the size of the programs they can
successfully process. Every implementation shall document
those limitations where known. This documentation may cite
fixed limits where they exist, say how to compute variable
limits as a function of available resources, or say that
fixed limits do not exist or are unknown. >>

On the other hand, "shall" ordinarily imposes requirements.

But even if this is a requirement, it doesn't require require that the
compiler document size limits, since the documentation can simply say
that they are unknown.
 
J

James Kanze

:"James Kanze" <[email protected]> wrote:
:On 21 mar, 13:25, "Ivan Vecerina" wrote::>
See the informative Annex B of the C++ standard, paragraph 1:
<< Because computers are finite, C++ implementations are
inevitably limited in the size of the programs they can
successfully process. Every implementation shall document
those limitations where known. This documentation may cite
fixed limits where they exist, say how to compute variable
limits as a function of available resources, or say that
fixed limits do not exist or are unknown. >>

Now that's an interesting paragraph in its own. In an
"informative" (non-normative annex), "every implementation
shall". There's a contradiction right there. But of course,
the "where known" lets the implementation off the hook.

(FWIW: that annex was the subject of some very intense debate
toward the beginning of the standardization process. There's a
lot of history involved there.)
 
J

James Kanze

"Informative" means that it does not impose requirements.
On the other hand, "shall" ordinarily imposes requirements.

Perhaps the project editor for the C++ standard could correct
that as an editorial problem:). (I'm not 100% sure, but I
think you were around when the issue was being discussed for
C90. I've forgotten much of the discussion---probably
subconsciously intentionally, but I'm pretty sure that there was
an intentional vote to move the "translation limits" to a
non-normative annex, rather than to have normative translation
limits as was the case in C90.)
 
P

Pete Becker

Perhaps the project editor for the C++ standard could correct
that as an editorial problem:). (I'm not 100% sure, but I
think you were around when the issue was being discussed for
C90. I've forgotten much of the discussion---probably
subconsciously intentionally, but I'm pretty sure that there was
an intentional vote to move the "translation limits" to a
non-normative annex, rather than to have normative translation
limits as was the case in C90.)

That's my recollection, too. But I'll have to check with a few people
to be sure that this wasn't somehow intentional.
 
I

Ivan Vecerina

: On 2008-03-22 10:41:43 -0400, "Ivan Vecerina"
: > :On 21 mar, 13:25, "Ivan Vecerina" wrote:
: > :> Size limits are platform specific (need to check documentation
: > :> of your compiler / computer).
: > :
: > :I don't think the compiler is required to document them, and
: > :quite frankly, I don't see how it could.
: >
: > James,
: > See the informative Annex B of the C++ standard, paragraph 1:
:
: "Informative" means that it does not impose requirements.

I know. I simply used this reference to show that it is not
unreasonable to invite someone to check the documentation
of his platform/compiler to look for restrictions on, for
instance, the maximum size of a local variable.

The OP faced an error trying to declare a large array, probably
as a local or static variable. I warned him that limits exist
(and suggested a way he could educate himself about them) before
inviting him to use dynamic memory allocation. I was genuinely
and simply trying to provide some helpful guidance to the OP.

The replies you (James and Pete) added to my post seem to
serve something else than this simple altruistic purpose.
Of course this is ok too... but maybe it is just a waste
of our time (yours and mine).

Kind regards --Ivan
 
J

James Kanze

On 23 mar, 02>53, "Ivan Vecerina"
I know. I simply used this reference to show that it is not
unreasonable to invite someone to check the documentation
of his platform/compiler to look for restrictions on, for
instance, the maximum size of a local variable.

Even if it weren't in the standard, such a suggestion wouldn't
be unreasonable from a logical point of view; it only makes
sense to document such factors, from a quality of implementation
point of view, at least.

Realistically, on the other hand, I've never been able to find
such documentation for any of the compilers I use, so I'm not
sure how effective the advice is practically.
The OP faced an error trying to declare a large array,
probably as a local or static variable. I warned him that
limits exist (and suggested a way he could educate himself
about them) before inviting him to use dynamic memory
allocation. I was genuinely and simply trying to provide some
helpful guidance to the OP.

I understand that. In practice, however, I'd be very surprised
if the advice worked.
The replies you (James and Pete) added to my post seem to
serve something else than this simple altruistic purpose. Of
course this is ok too... but maybe it is just a waste of our
time (yours and mine).

The dialog between Pete and I has nothing directly to do with
the original question. We're both interested in the standard,
per se (even when compilers don't strictly adher to it), and the
text you quoted does seem to be a contradiction in the standard,
which should be corrected. (The section is either normative, or
it shouldn't say "shall".) comp.std.c++ might be more
appropriate, but the thread started here, and of course,
comp.std.c++ seems to be dead at present.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top