Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > bugs in c

Reply
Thread Tools

bugs in c

 
 
Prashanth Badabagni
Guest
Posts: n/a
 
      10-15-2003
hi,
i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
C language whether programming or syntactical BUGS ....

Thanks in advance ...


Prashanth Badabagni
 
Reply With Quote
 
 
 
 
Joona I Palaste
Guest
Posts: n/a
 
      10-15-2003
Prashanth Badabagni <(E-Mail Removed)> scribbled the following:
> hi,
> i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
> C language whether programming or syntactical BUGS ....


How would you define a "bug" in a programming language? Keep in mind
that programming languages and *implementations* of programming
languages are different things entirely. For example, gcc, Turbo C, MS
Visual C, etc. are not languages, they're implementations of languages.

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"When a man talks dirty to a woman, that's sexual harassment. When a woman talks
dirty to a man, that's 14.99 per minute + local telephone charges!"
- Ruben Stiller
 
Reply With Quote
 
 
 
 
Robert Stankowic
Guest
Posts: n/a
 
      10-15-2003

"Prashanth Badabagni" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> hi,
> i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
> C language whether programming or syntactical BUGS ....
>
> Thanks in advance ...


Do you mean pitfalls? (you know, that features of a language which provide
enough ammunition to shoot yourself into your foot)
Well, C has plenty of them - it does not just give you the ammunition, it
gives you the gun as well, together with enough rope to hang yourself

Seriously, a good start will be to read the CLC FAQ at
http://www.eskimo.com/~scs/C-faq/top.html
and to get a good C-Book (IIRC there is a list of recommended books in the
FAQ)
Lurking around here for a while will also give you some valuable
information.
HTH
Robert


 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      10-15-2003
In <bmiu2a$hpb$(E-Mail Removed)> Joona I Palaste <(E-Mail Removed)> writes:

>Prashanth Badabagni <(E-Mail Removed)> scribbled the following:
>> hi,
>> i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
>> C language whether programming or syntactical BUGS ....

>
>How would you define a "bug" in a programming language?


A brain dead feature that renders the language less intuitive or easy to
use without any redeeming benefits. E.g. using + for the division
operator and / for the addition operator.

The precedence of the binary &, | and ^ operators is certainly a bug in C:
they should have had higher precedence than the equality operators.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      10-15-2003
Dan Pop <(E-Mail Removed)> scribbled the following:
> In <bmiu2a$hpb$(E-Mail Removed)> Joona I Palaste <(E-Mail Removed)> writes:
>>Prashanth Badabagni <(E-Mail Removed)> scribbled the following:
>>> hi,
>>> i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
>>> C language whether programming or syntactical BUGS ....

>>
>>How would you define a "bug" in a programming language?


> A brain dead feature that renders the language less intuitive or easy to
> use without any redeeming benefits. E.g. using + for the division
> operator and / for the addition operator.


> The precedence of the binary &, | and ^ operators is certainly a bug in C:
> they should have had higher precedence than the equality operators.


I agree that that is a bug if you define it in that way.

Off-topic for comp.lang.c, but I have to say that there is also such a
bug in Java: The fact that you can call static methods via instance
references is clearly brain-dead language design. After all, the call
doesn't *USE* the reference for anything other than finding out what
class it is. There's *NO WAY* to tell from the call statement whether
the method is static (and thus skips over polymorphism entirely) or
dynamic (in which case the implementation is found polymorphically).
You have to look at the method definition, which might well be in code
someone else wrote.

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"B-but Angus! You're a dragon!"
- Mickey Mouse
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      10-15-2003
Prashanth Badabagni wrote:

> hi,
> i'm prashanth Badabagni .. Can anyone tell me the BUGS present in
> C language whether programming or syntactical BUGS ....


Show us your C code, and we'll gladly do our best to tell you the bugs
present in that C code.

The C language itself has remarkably few bugs. That's why it's still a
phenomenally popular language 30 years on. If you want lots of bugs to chat
about in a CS essay, try some other language.

--
Richard Heathfield : (E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      10-15-2003
Dan Pop <(E-Mail Removed)> spoke thus:

> The precedence of the binary &, | and ^ operators is certainly a bug in C:
> they should have had higher precedence than the equality operators.


Hm. I suppose I'll ask... 1) What was the original rationale for that
design choice? 2) Why didn't C99 address it?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Arthur J. O'Dwyer
Guest
Posts: n/a
 
      10-15-2003

On Wed, 15 Oct 2003, Christopher Benson-Manica wrote:
>
> Dan Pop <(E-Mail Removed)> spoke thus:
> >
> > The precedence of the binary &, | and ^ operators is certainly a
> > bug in C: they should have had higher precedence than the equality
> > operators.

>
> Hm. I suppose I'll ask... 1) What was the original rationale for that
> design choice?


[DISCLAIMER: This whole thing is second-hand knowledge from memory.
I believe Dennis Ritchie once wrote an article on the topic; check
Google and Google Groups if you really want to know.]


Some pre-C language (i.e., maybe B, BCPL, or intermediates) had the
clever idea of overloading & and | in boolean contexts; that is,

(i < j & j < k)

would short-circuit and produce a boolean result (which in this
context means an integer 0 or 1), while

(i + j & j + k)

would *not* short-circuit (not even if i+j==0) and not necessarily
produce a boolean result.

When pre-standard C came along, it inherited this overloading. But
then the designers said, "Hey, this is really confusing!" and decided
to split & and | into (& and |) and (&& and ||), one pair for arithmetic
contexts and one pair for boolean contexts.

So some poor fool probably had to go through all the old pre-C code,
doing a search-and-replace on
if (i==j & j==k)
changing it to
if (i==j && j==k)
and so on. It would have been too much to ask of him to actually
change the *precedence* of the operators, as well as the spelling!
So && and || sneaked into the precedence table right below the
old & and | operators, and nobody had to add any parentheses.


> 2) Why didn't C99 address it?


What would C99 have done? Changed the precedence tables? Do
you have *any* idea how confusing that would be, especially when
some hapless newbie Googles "c precedence table" and finds that
the top two results contradict each other? Not to mention the
vast body of C89 code out there that would break if the precedences
were changed, or the annoyance it would cause to the designers of
C-like languages like C++, Java, et al. - which of the two precedence
tables would *they* use now?

Moral: Design well, and design early, because once a re-design
becomes a good idea, it's no longer a good idea.

-Arthur

 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      10-15-2003
Christopher Benson-Manica wrote:
>
> Dan Pop <(E-Mail Removed)> spoke thus:
>
> > The precedence of the binary &, | and ^ operators is certainly a bug in C:
> > they should have had higher precedence than the equality operators.

>
> Hm. I suppose I'll ask... 1) What was the original rationale for that
> design choice? 2) Why didn't C99 address it?


See

http://www.lysator.liu.se/c/dmr-on-or.html#main

--
(E-Mail Removed)
 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      10-15-2003
Arthur J. O'Dwyer <(E-Mail Removed)> scribbled the following:
> What would C99 have done? Changed the precedence tables? Do
> you have *any* idea how confusing that would be, especially when
> some hapless newbie Googles "c precedence table" and finds that
> the top two results contradict each other? Not to mention the
> vast body of C89 code out there that would break if the precedences
> were changed, or the annoyance it would cause to the designers of
> C-like languages like C++, Java, et al. - which of the two precedence
> tables would *they* use now?


> Moral: Design well, and design early, because once a re-design
> becomes a good idea, it's no longer a good idea.


So now the rule of thumb when dealing with C operator precedence is:
"If in doubt, use parantheses like they're going out of fashion."

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
- Mika P. Nieminen
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bugs and Bugs...get rid of them Jason Computer Security 1 01-31-2006 10:47 PM
BUGS ??? erha Wireless Networking 7 05-16-2005 02:34 PM
Still use 'ruby-bugs' for Ruby bugs? Josef 'Jupp' Schugt Ruby 2 11-04-2004 10:10 PM
Firefox 0.9.1 major bugs Jonathan Firefox 7 07-07-2004 11:28 PM
mozilla community (bugs) - how it works? SiD` Firefox 1 05-25-2004 02:44 PM



Advertisments