News for hackers. Stuff that matters.
Re:Deep C by toksaitov on Monday October 10, 2011 @12:13PM (#3094403)
"In real life, the boy may actually be a better programmer than the girl.”

I think in real life the boy will shoot himself in the leg without knowing the order of evaluation in C.

Re:Deep C by screwt on Monday October 10, 2011 @01:49PM (#3094901)
I'm worried that the girl will leave a loaded shotgun for someone else to shoot themselves in the leg by writing code that relies on order of evaluation rather than by using parantheses. The girl clearly knew her stuff, but I'd be much happier if she prefaced this example by also saying "it's dangerous to write code like this because...". I wouldn't want to work with someone who writes code that relies on all the features discussed in the C examples.
Re:Deep C by SamReidHughes on Monday October 10, 2011 @06:12PM (#3096112)
How would one write code that depends on order of evalution, instead of using parentheses? Where can you use parentheses that lets you write code that doesn't depend on order of evaluation? I think you missed something here because nothing about the example at hand has anything to do with the use of parentheses.
Re:Deep C by Dylan16807 on Tuesday October 11, 2011 @02:48PM (#3099801)
I'm actually worried the girl's going to shoot herself in the leg.

  void foo(void)
  {
    int a = 41;
    a = a++;
    printf("%d\n", a);
  }
She says 'a gets an undefined value' but that's not true at all. There are compilers that will look at that undefined function and omit the entire body, including the print.

It is extremely important to understand that undefined behavior can and will break everything, even if it appears to be behaving whenever you look.