Segmentation Fault....

M

Mark McIntyre

So it doesn't accept them if you explicitly tell it not to.

Ok, pedants corner: it accepts them if you allow it to engage language
extensions.

What, you thought that gcc invoked without any arguments was a
C99-conformant compiler ? Wow.
Wow, I'm impressed.

Allow me to sell you some snake oil, if you're *that* easily
impressed.



--
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
 
R

Richard Heathfield

jacob navia said:
I am speaking about standard C.

Fine, but you're speaking about a standard that almost nobody uses in
the real world. The de facto standard remains C90. I believe I am right
in saying that not even your own compiler conforms to C99.
 
R

Richard Tobin

This is a lie too.
[/QUOTE]
One day, someone is going to call you on this, and you'll end up in
court paying damages for libel or slander or whatever it is.

No, it's just rhetoric. No-one's reputation is going to be damaged by
Jacob calling something a lie in a flame about about C standards.
Except Jacob's of course, and even in the US you probably can't sue
yourself.

-- Richard
 
J

jacob navia

Mark McIntyre a écrit :
Not one of the above compilers will accept // comments *if invoked as
a conforming C compiler*. There's no option to engage C99 compliance
either, since they all predate that standard.

Fine. The examples (as I stated above) do not prove anything since they
are obsolete versions of of compilers that now do accept // comments.

This means that Heathfield examples are not any examples of a *current*
version of a compiler.
Incorrect. Even gcc 4.x will emit an error if you tell it to conform
to ANSI or C89 standards.




One day, someone is going to call you on this, and you'll end up in
court paying damages for libel or slander or whatever it is.

libel?
slander?

I did not insult anyone. I just call a lie a lie, since it is
misleading, and misleading people *is* lying. ALL those examples
are wrong, since if invoked in a mode where C89 compliance is NOT
required they wil all accept // comments, except those like Turbo C 2.0
that predate the invention of // comments!
 
F

Flash Gordon

Daniel Rudy wrote, On 10/04/07 22:34:
At about the time of 4/10/2007 2:30 PM, Army1987 stated the following:

No, I meant c89. I explicitly use -ansi -std=c89 for most of my C code.

long long is not part of C89 or C90. In fact, the difference between C89
and C90 is the paragraph numbering, so a compiler that conforms to one
by definition conforms to the other.

<OT>
Using both -ansi and -std=c89 is pointless since the two switches mean
the same thing in gcc.
</OT>
 
I

Ian Collins

jacob said:
Mark McIntyre a écrit :


Fine. The examples (as I stated above) do not prove anything since they
are obsolete versions of of compilers that now do accept // comments.

This means that Heathfield examples are not any examples of a *current*
version of a compiler.
This argument, as ever, will go nowhere.

There are those who prefer the more widely supported earlier standards
either for maximum portability or due to Luddite tendencies and there
are those who prefer the current standard or widely used extensions.

Neither way is the true path to enlightenment, so to each his or her own.
 
R

Richard Heathfield

jacob navia said:

The examples (as I stated above) do not prove anything since
they are obsolete versions of of compilers that now do accept //
comments.

Not in conforming mode, they don't.

I did not insult anyone. I just call a lie a lie, since it is
misleading, and misleading people *is* lying. ALL those examples
are wrong, since if invoked in a mode where C89 compliance is NOT
required they wil all accept // comments,

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.
except those like Turbo C
2.0 that predate the invention of // comments!

Typical Navia nonsense. // comments go at least as far back as BCPL,
which pre-dates C, let alone Turbo C.
 
J

jacob navia

Richard Heathfield a écrit :
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.

CONFORMING TO WHAT?????

Not to the C standard of course, but to the standard that
guru heathfield likes and prescribes for the masses.

And if I discuss standard C this is off topic in clc because
standard C is off topic here. What counts is the opinion of the
local guru...

"non-conforming mode" means for heathfield non conforming to
an obsolete standard even if it is conforming to the C standard.

And obviously if I point out that Mr Guru is wrong, all the
hell breaks loose and each and every one of the sect will
start screaming

HERESY HERESY...

:)

It is so ridiculous this stuff.

If a compiler accepts a feature defined in the standard it
is running in "NON CONFORMING MODE".

Yeah. Obvious.

Gurus are always right.
 
J

jacob navia

Ian Collins a écrit :
This argument, as ever, will go nowhere.

There are those who prefer the more widely supported earlier standards
either for maximum portability or due to Luddite tendencies and there
are those who prefer the current standard or widely used extensions.

Neither way is the true path to enlightenment, so to each his or her own.

I would accept that, but heathfield insists that anything different from
C89 is "off topic in clc". He is convinced that he can dictate what
can be discussed here.

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>

With "non conforming" he means in a mode that accepts standard
comments...
With "conforming mode" he means "conforming to MY favorite version of
the standard even if it is obsolete"

And anything else is off topic.

I can accept that heathfield has problems with C99 or that he doesn't
like blondies and only does it with brunettes. Who cares about his
likes and dislikes?

He can expose its reasons, I mean I have never accused anybody here with
"off topic" nonsense.

But what I do not accept is this "this is off topic in clc.
// comments are wrong."

NONSENSE I repeat!
 
G

Gregor H.

Find me a fully conforming C99 compiler and standard library in
widespread use, and I'll believe you.
Jacob is right and you are right too, Richard!

It's extremely strange (imho) that in the year 2007 (!) we still have TO LOOK
FOR conforming C99 compilers. Strange world... Therefor I try to code in C
conforming to C89/C90, i.e. "ANSI C" (except I'm coding in lcc-win32. ;-)


G.


BTW: Even lcc-win32 is NOT a fully conforming C99 compiler! Jacob! ;-)
 
I

Ian Collins

jacob said:
Ian Collins a écrit :


I would accept that, but heathfield insists that anything different from
C89 is "off topic in clc". He is convinced that he can dictate what
can be discussed here.

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>
Don't go there. All you will find is yet another futile "there aren't
any conforming C99 compilers" argument.
 
G

Gregor H.

Gurus are always right.
Sure. That's why THEY are Gurus, and WE are only // well forget about that.

Say, Jacob, how's about the C99 conformance of lcc-win32? (I'm just curious.
I'm a frequent user of lcc-win32.)


G.
 
R

Richard Heathfield

jacob navia said:
Richard Heathfield a écrit :

CONFORMING TO WHAT?????

The only ISO C Standard they support - i.e. C90.

Not to the C standard of course,

The same Standard that lcc-win32 conforms to (if it does indeed conform
to C90, which I haven't checked).
but to the standard that
guru heathfield likes and prescribes for the masses.

No, I don't prescribe it at all. I simply describe current reality. If
you want C99 to be universally available, get busy writing and
distributing C99 compilers.
And if I discuss standard C this is off topic in clc because
standard C is off topic here.

No, standard C is topical here. And // comments are part of standard
C99, so they're topical. The fact that they're stupid is neither here
nor there - they are topical regardless.
What counts is the opinion of the local guru...

No, the important factors are topicality and practicality.
"non-conforming mode" means for heathfield non conforming to
an obsolete standard even if it is conforming to the C standard.

None of the compilers I mentioned has a C99-conforming mode, and in this
regard they are no different to most C compilers. So, for them,
conforming mode clearly refers to C90.
And obviously if I point out that Mr Guru is wrong, all the
hell breaks loose and each and every one of the sect will
start screaming

HERESY HERESY...

No, but I will point out that your article was a very good example of
the Navia genre, in that every single point in it was wrong.
 
O

Old Wolf

I'm coding this simple program, but I get a segmentation fault

You have problems with array indexing (as well as the scanf problem).
double vsum(double x[20], int n){
int i;
float Result = 0;

//Calculation for - Sum of numbers
for (i=1;i<=n;i++){
Result += x;
}
return Result;
}


This code never uses x[0], and if n is 20 then it will read x[20]
which might cause a segfault. If an array has 20 elements then
their indices are 0,1,2,3,...,18,19 .

In case you aren't aware, array 'dimensions' in function parameter
lists are actually ignored by the compiler, they are only for user
documentation purposes really. Your code works exactly the same as
if it were:

double vsum(double x[], int n)

or even

double vsum(double *x, int n)
//Calculation for - Sum of the numbers squared
for (i=1;i<n+1;i++){
Number = x;
Result += pow(Number,2);
}

double Array[20]; // Array to store numbers
scanf(" %f", &NumOfNum);

Should be %d of course.
//Adds numbers into array & calculation for sum of numbers
for (i=0;i<=NumOfNum;i++){

What will happen if they enter 20, or -1, or 500, or "X" ?
You should check that scanf() returns 1 (indicating that it
successfully read one value), and also check the value is
in the range of 1 through 19.

Also, if they enter "2" then this loop will run through 3 times,
with 'i' being 0, then 1, then 2. Is that what you wanted?
printf("\nEnter the value for number %d \n", Count);
scanf(" %f", &Number);

Again, check the result of scanf.
 
I

Ian Collins

Richard said:
No, standard C is topical here. And // comments are part of standard
C99, so they're topical. The fact that they're stupid is neither here
nor there - they are topical regardless.
There you go again, can't you just accept some of us prefer them in
certain contexts? Why is it that anything you don't like has to be stupid?
 
R

Richard Heathfield

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

No, I don't. C99 is topical here, and I have never claimed otherwise.
He is convinced that he can dictate what can be discussed here.

No, I'm not, and no, I can't.
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>

With "non conforming" he means in a mode that accepts standard
comments...

A C99-conforming compiler must accept // comments. A C90-conforming
compiler must diagnose // syntax errors. All the compilers I mentioned
were C90-conforming. None of them were C99-conforming.
With "conforming mode" he means "conforming to MY favorite version of
the standard even if it is obsolete"

No, in this case I was referring to implementations that conform to C90,
which is far from obsolete (after all, even lcc-win32 conforms to C90
rather than C99, right? And I'm sure you won't be claiming that your
own compiler is obsolete).

But what I do not accept is this "this is off topic in clc.
// comments are wrong."

But I do not claim that // comments are wrong or off-topic in clc.
NONSENSE I repeat!

Yes, you do - over and over again.
 
R

Richard Heathfield

Gregor H. said:

BTW: Even lcc-win32 is NOT a fully conforming C99 compiler! Jacob! ;-)

And therefore, according to Jacob Navia, lcc-win32 is obsolete.
 
J

jacob navia

Gregor H. a écrit :
Sure. That's why THEY are Gurus, and WE are only // well forget about that.

Say, Jacob, how's about the C99 conformance of lcc-win32? (I'm just curious.
I'm a frequent user of lcc-win32.)


G.

Well, I have implemented most of it, and written the library. It has
been a huge effort, and it is still not finished.

Done are

Data types:
o complex
o long long
o bool

Declarations:
o Declarations anywhere in a block
o Variable length arrays
o Flexible structures

Library:
printf completely rewritten
Floating point exception handling (fe* functions)
All the new math functions like erf lgamma, etc.
All other new functions required.
Implemented tgmath.h

Not done yet is:

Designated specifiers.

and

Variable argument macros.
The reason is that the preprocessor of lcc-win32 was written
originally by Dennis Ritchie. I have used it since a
long time, and added some stuff to it, fixed some simple bugs, but I
have left the code running as he conceived it. He wrote that
preprocessor for his Plan 9 system, and put it in the public domain.

I have used it, but I want to leave it somehow untouched. I have
implemented some of the ideas of his Plan 9 system in my compiler, for
instance the structure member lookup, what allows some form of
inheritance. But that is another discussion.

jacob
 
G

Gregor H.

And // comments are part of standard C99, so they're topical.
Right.


The fact that they're stupid is neither here nor there - they
are topical regardless.
Well. Why do you think they are "stupid"? As far as I know C++ had them first
and later the guys from the ANSI/ISO committee decided to have them in C too.
Though it's rather unlikely imho that they are (just plain) stupid. In fact I
use them regularly (in not strictly conforming "ANSI C" code). 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).


G.
 
G

Gregor H.

Well, I have implemented most of it, and written the library. It has
been a huge effort ...
Yes. I know.

Even gcc is still not conforming to C99.
, and it is still not finished.
Yes. I'm sure it's a hell lot of work!
Done are

Data types:
o complex
o long long
o bool

Declarations:
o Declarations anywhere in a block
o Variable length arrays
o Flexible structures

Library:
printf completely rewritten
Floating point exception handling (fe* functions)
All the new math functions like erf lgamma, etc.
All other new functions required.
Implemented tgmath.h
Good thing.
Not done yet is:

Designated specifiers.

and

Variable argument macros.
The reason is that the preprocessor of lcc-win32 was written
originally by Dennis Ritchie. I have used it since a
long time, and added some stuff to it, fixed some simple bugs, but I
have left the code running as he conceived it. He wrote that
preprocessor for his Plan 9 system, and put it in the public domain.

I have used it, but I want to leave it somehow untouched. I have
implemented some of the ideas of his Plan 9 system in my compiler, for
instance the structure member lookup, what allows some form of
inheritance. But that is another discussion.
I see. (Way out?)

Thanx for all your good work, Jacob. (And don't waste your time with pointless
discussions with our local gurus. ;-)


G.


P.S.
I'm looking forward to a 64-bit version of win-lcc. :)
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top