§ ¶Don't code at 1am, round two
Found this in VirtualDub's render path while debugging some issues with the input driver API. Do you see the bugs? I spotted the first one immediately, but almost posted a new test release to the forums before spotting the second.
frameInfo.mRawFrame = stream_frame;
frameInfo.mTimelineFrame = target_frame,
frameInfo.mDisplayFrame = display_frame;
frameInfo.mTimelineFrame = timeline_frame;
You have a comma instead of a semi-colon on the second line and you are setting mTimelineFrame twice. Took me a while to see the second one :-)
Paul - 07 10 07 - 21:20
I noticed the double mTimelineFrame immediately, but it took me a while to find the comma bug.
The interesting question now is: which one did you spot immediately, and which one took you longer?
Darkstar - 08 10 07 - 04:09
You've assigned both target_frame and timeline_frame to mTimelineFrame. There may also be an error in assigning stream_frame to mRawFrame, but that depends on what your code is doing.
I didn't spot the comma until after reading through the other comments. That's something that either the IDE will show through strange highlighting, or the compiler will explode messily on.
Thomas (link) - 08 10 07 - 06:13
Thomas: No, that comma thing is actually perfectly valid C(++). The only thing the compiler might complain about is that target_frame is accessed but discarded.
(Oh, and BTW, I didn't spot it until cheati^Wreading the other comments, too :)
KeyJ (link) - 08 10 07 - 12:54
the "mTimelineFrame" people were having a "buy-one-get-one-free" sale.
roseman - 09 10 07 - 11:01
@KeyJ: It is?
/me looks up comma in MSVC docs
Apparently it is. If I'm reading the docs right, then with the code shown it'll work as intended with no side effects. Looking at the docs, it looks like one could replace most semicolons with commas and have programs still work.
Thomas (link) - 09 10 07 - 16:55
If you were aiming at consistency in your functions and properties names, I'd say that frameInfo.mRawFrame should reference something called raw_frame, not stream_frame - or that the property should be renamed frameInfo.mStreamFrame.
So maybe the second bug is a mis-reference.
If the name change is voluntary, then I don't know.
Mitch 74 - 12 10 07 - 09:41
omg, what can i comment? they all talking about what the hell that comma was doing there? well, i dont know, caz i am not a programmer, I only want a good optimized and improved virtualdb that guy is making there.
BTW: i posted this caz i read at this page: |please keep comments on-topic for this entry"
balad - 13 10 07 - 16:26
Nah, the comments are fine -- this entry's more about coding than VirtualDub itself. The comma is amusing because it's definitely not what I had intended and means something different to the compiler, but it just happens to work.
Phaeron - 13 10 07 - 16:38
I spotted the missing semi-colon immediately, mTimelineFrame looked suspicious but I dont the API that well..
Councils Ov Therion - 19 10 07 - 22:57
Eh, you should have seen me debugging some code compiled with Intel compiler, which refused to set global variables (of type double) to their initial values. Actually, it did initialize them but the values were randomly wrong.
I submitted an issue but their developer couldn't reporduce the issue and he sent me this code example saying that someone else reported it and that it looks similar to my issue:
double somefunc(double a)
return a * 1.18;
Compiler kept optimizing the multiplication out thus always returning what was passed in. I tried it and I was able to reproduce the problem and he was puzzled because he wasn't able to reproduce that one either.
Then I had one of those blinding flashes and the train of thought went like this:
1. a * 1.18 = adding tax (I am from Serbia, tax is 18%)
2. What do I have in common with that person?
3. (slaps forehead) Regional Settings!
It turned out that the compiler was mistakenly honoring regional settings and swapped "." and "," so the code turned into:
return a * 1,18;
I told their developer to change his regional settings to any locale where "." and "," were reversed and lo and behold -- he managed to reproduce the problem.
In my opinion that is the worst kind of bug you can hit -- you can't see it because it is not yours.
Igor (link) - 07 01 08 - 22:11
Please keep comments on-topic for this entry.
If you have unrelated comments about VirtualDub, the forum is a better place to post them.