www.digitalmars.com         C & C++   DMDScript  

c++.chat - Bug or No Bug ??? - test.cpp

The attached file is a small program that creates 2 classes.
all functions are defined inline.

The operator<< is overloaded to be able to sent to the object everything that
neeeds to be done.

The first class cTestIf has an if-statement in the operator<<(char *_txt)
the second class cTestNot has this if-statement in a shortened version

I was quite surprised seeing that both reacted differently :

the first :
I*IHello World!I*
I*IHello World!I*
I*IOne Step BeyondI*

the string only gets updated after the whole line is processed

the second
N*NHello World!N*
N*NOne Step BeyondN*
N*NStep TwoN*

the string is updated before the next operator<< is executed

Is this normal behaviour or is this a bug in how the 2 if-statements are treated
by dmc compiler/linker ?

--

Nascar

Mens Sana In Corpore Sano
begin 0644 test.cpp
M(VEN8VQU9&4 /&EO<W1R96%M+F ^#0H-"F-L87-S(&-497-T268-"B![#0H 
M('!R:79A=&4Z#0H ("` 8VAA<B`J='AT.PT*("!P=6)L:6,Z#0H ("` 8U1E
M<W1)9BAC:&%R("I?='AT/4Y53$PI#0H ("` ('L 8VAA<B`J='0];F5W(&-H
M87);<W1R;&5N*%]T>'0I73L <W1R8W!Y*'1T+%]T>'0I.R!T>'0]='0[('T-
M"B` ("!^8U1E<W1)9B I('L .R!]#0H ("` #0H ("!C:&%R*B!497AT*"D-
M"B` ("` >R!R971U<FX ='AT.R!]#0H ("`-"B` (&-497-T268F($YE=U1E
M>'0H8VAA<B`J7W1X=#U.54Q,*0T*("` ("![(&-H87( *G1T/6YE=R!C:&%R
M6W-T<FQE;BA?='AT*5T[('-T<F-P>2AT="Q?='AT*3L ='AT/71T.R!R971U
M<FX *G1H:7,[('T-"B` ("` #0H ("!C5&5S=$EF)B!O<&5R871O<CP\*&-4
M97-T268F(%]T<W0I#0H ("` ('L <F5T=7)N(%]T<W0[('T-"B` (&-497-T
M268F(&]P97)A=&]R/#PH8VAA<BH 7W1X="D-"B` ("` >R!I9B Q*2!C;W5T
M(#P\("))(CL #0H ("` ("` 96QS92!C;W5T(#P\("))22([#0H ("` ("` 
M8V]U="`\/"!?='AT.R!R971U<FX *G1H:7,[('T-"B!].PT*#0IC;&%S<R!C
M5&5S=$YO=`T*('L-"B` <')I=F%T93H-"B` ("!C:&%R("IT>'0[#0H ('!U
M8FQI8SH-"B` ("!C5&5S=$YO="AC:&%R("I?='AT/4Y53$PI#0H ("` ('L 
M8VAA<B`J='0];F5W(&-H87);<W1R;&5N*%]T>'0I73L <W1R8W!Y*'1T+%]T
M>'0I.R!T>'0]='0[('T-"B` ("!^8U1E<W1.;W0H*2![(#L ?0T*("` (`T*
M("` 8VAA<BH 5&5X=" I#0H ("` ('L <F5T=7)N('1X=#L ?0T*("` #0H 
M("!C5&5S=$YO="8 3F5W5&5X="AC:&%R("I?='AT/4Y53$PI#0H ("` ('L 
M8VAA<B`J='0];F5W(&-H87);<W1R;&5N*%]T>'0I73L <W1R8W!Y*'1T+%]T
M>'0I.R!T>'0]='0[(')E='5R;B`J=&AI<SL ?0T*("` ("`-"B` (&-497-T
M3F]T)B!O<&5R871O<CP\*&-497-T3F]T)B!?='-T*0T*("` ("![(')E='5R
M;B!?='-T.R!]#0H ("!C5&5S=$YO="8 ;W!E<F%T;W(\/"AC:&%R*B!?='AT
M*0T*("` ("![(#$_8V]U="`\/"`B3B(Z8V]U="`\/"`B3DXB.R`-"B` ("` 
M("!C;W5T(#P\(%]T>'0[(')E='5R;B`J=&AI<SL ?0T*('T[#0H-" T*=F]I
M9"!M86EN*"D-"GL-"B!C5&5S=$EF('1E<W0H(DAE;&QO(%=O<FQD(2(I.PT*
M#0H =&5S="`\/"`B*B( /#P =&5S="Y497AT*"D /#P (BI<;B([#0H =&5S
M="`\/"!T97-T+DYE=U1E>'0H(D]N92!3=&5P($)E>6]N9"(I(#P\("(J(B`\
M/"!T97-T+E1E>'0H*2`\/"`B*EQN(CL-"B!T97-T(#P\('1E<W0N3F5W5&5X
M=" B4W1E<"!4=V\B*2`\/"`B*B( /#P =&5S="Y497AT*"D /#P (BI<;B([
M#0H-"B!C5&5S=$YO="!T97-T,B B2&5L;&\ 5V]R;&0A(BD[(&-O=70 /#P 
M96YD;#L-" T*('1E<W0R(#P\("(J(B`\/"!T97-T,BY497AT*"D /#P (BI<
M;B([#0H =&5S=#( /#P =&5S=#(N3F5W5&5X=" B3VYE(%-T97` 0F5Y;VYD
M(BD /#P (BHB(#P\('1E<W0R+E1E>'0H*2`\/"`B*EQN(CL-"B!T97-T,B`\
M/"!T97-T,BY.97=497AT*")3=&5P(%1W;R(I(#P\("(J(B`\/"!T97-T,BY4
497AT*"D /#P (BI<;B([#0I]#0IP
`
end
Oct 26 2004