Segmentation Fault....

G

Gregor H.

And therefore, according to Jacob Navia, lcc-win32 is obsolete.
Well, I guess it has a future too. (At least I hope so!)


G.


P.S.
Imho it's a _very_ strange thing that even gcc is STILL not completely
conforming. (Jacob is just ONE guy, but the gnus..., you know.)
 
R

Richard Heathfield

Ian Collins said:
There you go again, can't you just accept some of us prefer them in
certain contexts?

Yes, of course I can accept that.
Why is it that anything you don't like has to be stupid?

If I've told you once, I've told you (size_t)-1 times - don't
exaggerate. I don't like rice pudding, but I don't think it's stupid.
But // comments are a very silly idea, especially in Usenet because
they make code very sensitive to line-wrapping (and of course because
of the whole non-portability issue).
 
R

Richard Heathfield

Gregor H. said:
Well. Why do you think they are "stupid"?

Line-wrap (eg in Usenet) breaks them, they generate diagnostics on
C90-conforming implementations, and in any case if the comment is so
short that it fits on one line, it probably isn't a very good comment
(well, either that or the guy writing the comment is a very good writer
indeed).
As far as I know C++ had them first

No, they pre-date C.
One nice thing concerning // comments: you
can comment out large blocks of code with /* .. */ not getting into
conflict with /* comments */ already there (in these blocks).

Comments should describe code, not remove it. If you want temporarily to
disable a block of code, you will find that

#if 0

code to be temporarily disabled

#endif

is much cleaner.
 
I

Ian Collins

Richard said:
Ian Collins said:


Yes, of course I can accept that.


If I've told you once, I've told you (size_t)-1 times - don't
exaggerate.

I'm not. You do tend to be dogmatic.
I don't like rice pudding, but I don't think it's stupid.
But // comments are a very silly idea, especially in Usenet because
they make code very sensitive to line-wrapping (and of course because
of the whole non-portability issue).
Silly on Usenet I'll grant you, but stupid in general? Just about every
compiler over the past decade and a half as accepted them as an
extension, so there are many out there who would disagree with you.
 
R

Richard Heathfield

Ian Collins said:
I'm not. You do tend to be dogmatic.

Woof. :)
Silly on Usenet I'll grant you, but stupid in general?
Yes.

Just about
every compiler over the past decade and a half as accepted them as an
extension, so there are many out there who would disagree with you.

Er, so what?
 
B

Bill Pursell

I'm coding this simple program, but I get a
segmentation fault, I'm
pretty sure that the arrays are big enough
and there isn't really any
buffer overflows so why is this happening?


You will do yourself a huge favor by spending
some time learning to use a debugger. It makes
tracking down problems like this much easier.
For example, when I run your code in the debugger,
it shows me that it segfaulted in the following
place:
#0 0x08048459 in vsum (x=0xbfeb70d0, n=1082130432) at a.c:28

We see that vsum was passed an argument of
n=1082130432, which is substantially larger than
the 20 elements allocated for x. In this
case, the problem is easier to track down if
you pay attention to the compiler warning:
a.c:70: warning: float format, different type arg (arg 2)

As an aside: you might want to check the number
entered and emit an error if the user wants
to sum more than 20 numbers. Or, better still,
don't use a fixed size of 20, but allocate space after
the user enters a number. Better yet, don't
make the user enter the number of entries
they intend to make: just let them enter
numbers until they're done.
 
R

Richard Heathfield

Bill Pursell said:
You will do yourself a huge favor by spending
some time learning to use a debugger. It makes
tracking down problems like this much easier.

I can vouch for this, but I can think of something far more effective -
learning the language.

Having actually learned C (rather than merely the language which the
books and my work colleagues believed to be C, which I'd already been
using for almost a decade), I found that the amount of debugging time I
needed had plummeted, and the number of times I needed to step through
code in a debugger had fallen to - effectively - zero.

Nowadays, my principal use of gdb is just to analyse the occasional core
dump (at which it excels).
 
D

Daniel Rudy

At about the time of 4/10/2007 2:37 PM, jacob navia stated the following:
Daniel Rudy a écrit :

Yes. If you tell gcc not to use the current standard but some other old
one it will not accept standard syntax.

WOW, how clever you are.

Considering that gcc's default is gnu99, which is some c99 with gnu
extensions, that's not really considered standard C either.
I am speaking about standard C. Nobody forces you to use anything
and if you do not like standrad C I do not care. But I do not want
to allow that you pass YOUR preferences as standard C. They are not.

You are speaking about a C standard that current compilers only
partially support. C89/C90 is the standard that is supported by most,
if not all current compilers. Since C99 support is hit and miss at
best, people are better off coding to C89/C90.
Great!!!

But that is not standard C. Clear?

Yes, it is standard C. It's the current conforming standard that is
fully supported by most if not all current compilers. I don't know of
any C compiler that fully supports C99 standard. So what's the point of
calling something a standard when nothing supports it...or partially
supports it?

So, you use the feature set that the compiler supports, and then if you
change C compilers for some reason. Guess what? If your new compiler
doesn't at least support the same feature set that the old one does,
your code doesn't compile.

Until compilers catch up to fully implementing C99, C89/C90 *is* the
current standard, regardless of what you might think. Show me a C
compiler that is fully C99 compilant (coding and libs) then I'll believe
you.

Gcc is at the cutting edge of compiler development, then not even it is
fully C99 compliant. Even Microsoft's C compiler isn't fully compliant.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
D

Daniel Rudy

At about the time of 4/10/2007 2:46 PM, Mark McIntyre stated the following:
Given that its likely that the /overwhelming/ majority of C compilers
in commercial use don't conform to C99, that remark seems absurd.

I fully agree.

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
C

Charlton Wilbur

RH> But // comments are a very silly idea, especially in Usenet
RH> because they make code very sensitive to line-wrapping (and of
RH> course because of the whole non-portability issue).

ian> Silly on Usenet I'll grant you, but stupid in general?

RH> Yes.

This is, I will note, a point I made in my original post on the
subject, completely ignored by Mr Navia in his rush to "correct" me by
posting chapter and verse supporting a statement I had made.

ian> Just about every compiler over the past decade and a half as
ian> accepted them as an extension, so there are many out there who
ian> would disagree with you.

RH> Er, so what?

Indeed. If ten million people do a stupid thing, it is still a stupid
thing.

Charlton
 
C

Christopher Benson-Manica

Richard Heathfield said:
jacob navia said:
(the usual rejoinder)

I understand the desire (and, to a lesser extent, need) to continue to
clarify and correct Mr. Navia's statements concerning C99, as well as
the topicality of such clarifications and corrections. However, I
humbly submit that I might not be the only reader of c.l.c who finds
the obligatory rehashing of oft-covered ground to be singularly
uninteresting, as well as a hinderance to reading other posts in the
same thread which may cover new ground. I would propose, as an
alternative to adding Mr. Navia and the other regular participants in
these recurring flame sessions to one's killfile, a tag of some
sort - perhaps "C99F" - to these posts as a courtesy to those of us who
prefer to read as few C99-related flames as possible.
 
R

Richard Heathfield

Christopher Benson-Manica said:
I understand the desire (and, to a lesser extent, need) to continue to
clarify and correct Mr. Navia's statements concerning C99, as well as
the topicality of such clarifications and corrections. However, I
humbly submit that I might not be the only reader of c.l.c who finds
the obligatory rehashing of oft-covered ground to be singularly
uninteresting,

I agree entirely. It's dull dull dull dull dull, isn't it? But what do
we do - just take it as read that anything he writes is wrong? And if
so, who tells the newbies?
as well as a hinderance to reading other posts in the
same thread which may cover new ground. I would propose, as an
alternative to adding Mr. Navia and the other regular participants in
these recurring flame sessions to one's killfile, a tag of some
sort - perhaps "C99F" - to these posts as a courtesy to those of us
who prefer to read as few C99-related flames as possible.

That might work too. I'll try to remember to do that. (Presumably F451
is out of the question?)
 
C

Charlton Wilbur

RH> Having actually learned C (rather than merely the language
RH> which the books and my work colleagues believed to be C, which
RH> I'd already been using for almost a decade), I found that the
RH> amount of debugging time I needed had plummeted, and the
RH> number of times I needed to step through code in a debugger
RH> had fallen to - effectively - zero.

I disagree; from my experience learning C meant that I was no longer
using the debugger to verify that I was passing what I meant to pass,
i.e., that my syntax and use of C was correct, but that my algorithm
was correct. An incorrect algorithm expressed in correct C (or a
correct algorithm incorrectly expressed in correct C) will still
produce the wrong answer, and single-stepping through the algorithm is
a useful diagnostic tool.

It also helps diagnose things off-topic in this newsgroup; for
instance, a system-specific function that does not return what I
thought it returned. Knowing I'm getting 0xaf51e2 when I expect
something in the range 0 to 4 means I misunderstood something and it's
time to look up the documentation.

Charlton
 
C

Christopher Benson-Manica

Richard Heathfield said:
I agree entirely. It's dull dull dull dull dull, isn't it? But what do
we do - just take it as read that anything he writes is wrong? And if
so, who tells the newbies?

Well, as I said, I do see the need for some diligence, and given the
obvious tediousness of the task, it's admirable that you've
volunteered. Alas, many (me) are of unequal resolve.
(I said):
That might work too. I'll try to remember to do that. (Presumably F451
is out of the question?)

Thanks; any subthreads that are thus eliminated from view will be much
appreciated. (F451 might be an acceptable tag for Schildt-related
posts.)
 
D

Default User

Richard said:
Christopher Benson-Manica said:

That might work too. I'll try to remember to do that. (Presumably
F451 is out of the question?)

Anything, so long as it's reasonably distinctive.




Brian
 
M

Mark McIntyre

Ian Collins a écrit :

I would accept that, but heathfield insists that anything different from
C89 is "off topic in clc".

No he does not. He does however frequently point out that extant C
compilers largely don't support C99 yet.
He is convinced that he can dictate what can be discussed here.

Paranoia isn't reasoned argument.
In the other answer in this same thread he says:

<quoting>
If an implementation is invoked in a non-conforming mode, that
invocation is off-topic in clc. When invoked in conforming mode, all
the compilers I mentioned issue the necessary diagnostic message for a
// syntax error.
< end quote>

And this is completely true. When the compilers he mentioned are
invoked in conforming mode, they do indeed produce a diagnostic.

This is because /they/ conform to C89, not because of some
machiavellian plot by RJH.
With "conforming mode" he means "conforming to MY favorite version of
the standard even if it is obsolete"

No, he means by passing the flags which make those compilers comply to
the standard they know about.

Do you not consider it just a tiny bit silly to insist that a compiler
written in 1998 conforms to C99?

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Richard Heathfield a écrit :

CONFORMING TO WHAT?????

The standard that was extant at the time they were written. What did
you expcet them to do, time travel?

Don't you see how foolish you're being?
Gurus are always right.

The only person who is saying that is you.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

There you go again, can't you just accept some of us prefer them in
certain contexts?

For what its worth, RJH has NOT denied that you or some others (myself
included) like the C++ comment style.
Why is it that anything you don't like has to be stupid?

Out of interest, do /you/ regard things you don't like as sensible,
beautiful and enviable? Of course not.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Silly on Usenet I'll grant you, but stupid in general? Just about every
compiler over the past decade and a half as accepted them as an
extension, so there are many out there who would disagree with you.

Hmm, good argument. Ten million lemmings can't be wrong. Big Brother
must be classy because a horde of cretins watch it. Er...


--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top