Click here to Skip to main content
15,899,475 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: One guidelines for C/C++ programmer Pin
Nemanja Trifunovic9-Sep-08 5:13
Nemanja Trifunovic9-Sep-08 5:13 
GeneralRe: One guidelines for C/C++ programmer Pin
ed welch11-Sep-08 13:02
ed welch11-Sep-08 13:02 
GeneralRe: One guidelines for C/C++ programmer Pin
Joe Woodbury14-Sep-08 9:45
professionalJoe Woodbury14-Sep-08 9:45 
GeneralRe: One guidelines for C/C++ programmer Pin
ed welch12-Sep-08 2:41
ed welch12-Sep-08 2:41 
NewsRe: One guidelines for C/C++ programmer Pin
Johann Gerell12-Sep-08 3:16
Johann Gerell12-Sep-08 3:16 
GeneralRe: One guidelines for C/C++ programmer Pin
asadullah ansari25-May-10 15:45
asadullah ansari25-May-10 15:45 
AnswerRe: One guidelines for C/C++ programmer Pin
Johann Gerell25-May-10 20:40
Johann Gerell25-May-10 20:40 
GeneralRe: One guidelines for C/C++ programmer Pin
PIEBALDconsult12-Sep-08 4:17
mvePIEBALDconsult12-Sep-08 4:17 
Depends on the compiler:

Borland C++ 5.5 for Win32 reports:
Warning W8060 xtc.c 14: Possibly incorrect assignment in function main




As usual, HP C V7.3-009 on OpenVMS Alpha V8.3 takes it to a whole other level:

CHECK Messages reporting code or practices that,
although correct and perhaps portable, are
sometimes considered ill-advised because
they can be confusing or fragile to
maintain. For example, assignment as the
test expression in an "if" statement.

NOTE: The check group gets defined by
enabling LEVEL5 messages.

LEVEL4 Useful check/portable messages.

LEVEL5 Not so useful check/portable messages.


CC/WARNING=(ENABLE=LEVEL5,VERBOSE) TEST.C

if ( argc = 1 )
....^
%CC-I-CONTROLASSIGN, In this statement, the assignment expression "argc=1" is used as the controlling expression of an if, while or for statement.
at line number 14 in file MY$ROOT:[000000]TEST.C;2
Description: A common user mistake is to accidentally use assignment operator "=" instead of the equality operator "==" in an expression that controls a transfer. For example sayin
g if (a = b) instead of if (a == b). While using the assignment operator is valid, it is often not what was intended. When this message is enabled, the compiler will detect these
cases at compile-time. This can often avoid long debugging sessions needed to find the bug in the user's program.
User Action: Make sure that the assignment operator is what is expected.

printf ( "Hello, %s!" , argv [ 1 ] ) ;
........^
%CC-I-IGNORECALLVAL, In this statement, the value returned from the function "printf(...)" is not used - if this is intended, it should be cast to "void".
at line number 16 in file MY$ROOT:[000000]TEST.C;2
Description: A function that returns a value has been invoked, yet the value was not used. This might not have been what you intended.
User Action: Cast the function to void to suppress the message.




CC/WARNING=(ENABLE=CONTROLASSIGN) TEST.C

if ( argc = 1 )
....^
%CC-I-CONTROLASSIGN, In this statement, the assignment expression "argc=1" is used as the controlling expression of an if, while or for statement.
at line number 14 in file MY$ROOT:[000000]TEST.C;2
GeneralRe: One guidelines for C/C++ programmer Pin
Dan Neely12-Sep-08 5:46
Dan Neely12-Sep-08 5:46 
GeneralRe: One guidelines for C/C++ programmer Pin
ClementsDan9-Sep-08 22:08
ClementsDan9-Sep-08 22:08 
GeneralRe: One guidelines for C/C++ programmer Pin
Pete O'Hanlon11-Sep-08 11:08
mvePete O'Hanlon11-Sep-08 11:08 
GeneralRe: One guidelines for C/C++ programmer Pin
cpkilekofp25-Sep-08 4:08
cpkilekofp25-Sep-08 4:08 
GeneralRe: One guidelines for C/C++ programmer Pin
Julian Nicholls25-May-10 5:01
Julian Nicholls25-May-10 5:01 
GeneralHi. Pin
vinay_K8-Sep-08 0:05
vinay_K8-Sep-08 0:05 
GeneralWell, Pin
CPallini8-Sep-08 0:09
mveCPallini8-Sep-08 0:09 
GeneralRe: Well, Pin
vinay_K8-Sep-08 0:17
vinay_K8-Sep-08 0:17 
GeneralRe: Well, Pin
CPallini8-Sep-08 0:38
mveCPallini8-Sep-08 0:38 
GeneralRe: Well, Pin
leppie8-Sep-08 0:46
leppie8-Sep-08 0:46 
GeneralRe: Well, Pin
CPallini8-Sep-08 0:59
mveCPallini8-Sep-08 0:59 
GeneralRe: Well, Pin
Christian Graus8-Sep-08 1:16
protectorChristian Graus8-Sep-08 1:16 
GeneralRe: Well, Pin
vinay_K8-Sep-08 1:51
vinay_K8-Sep-08 1:51 
GeneralRe: Well, Pin
Christian Graus8-Sep-08 5:43
protectorChristian Graus8-Sep-08 5:43 
GeneralRe: Well, Pin
vinay_K8-Sep-08 1:55
vinay_K8-Sep-08 1:55 
GeneralRe: Well, PinPopular
Baconbutty8-Sep-08 2:18
Baconbutty8-Sep-08 2:18 
GeneralRe: Well, Pin
vinay_K8-Sep-08 2:24
vinay_K8-Sep-08 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.