Thread: A method to improve compiler troubleshooting skills

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    72

    A method to improve compiler troubleshooting skills

    I think a good exercise to learn and troubleshoot different errors is to take a fairly complex program, say at least half a k-loc, in a one-file .c or .cpp, that compiles and executes just fine in any environment.

    Then accompany it with exercises to break the code in different ways, e.g.

    1: Remove semicolon at the end of line and compile
    2: Run a non-input params function without () and compile
    3: Assign value to the destination of a pointer without checking whether it is a null-pointer, compile and execute
    4: Assign a negative value to an unsigned variable compile and execute
    5: assign value to array[10] with size(array) = 10 or less and compile and execute
    6: Use the std::numeric_limits<float>::epsilon (without ()) in a context and compile.

    ...

    Analyze the error messages and describe what they mean. Any interesting error messages or program crashes that have taken a looong time to troubleshoot?

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    I think you want to look for "static analysis". Most of the errors you mention will be caught by the compiler by turning on warnings, or using various extra "linters" on your code.

    5: assign value to array[10] with size(array) = 10 or less and compile and execute
    Some simple cases of this error can be found with static analysis (e.g. cppcheck). To discover it dynamically you can try a tool like Valgrind with sgcheck. You should also use a coverage analysis tool to make sure you are actually exercising all of the program.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help troubleshooting
    By blackfox_1109 in forum C Programming
    Replies: 2
    Last Post: 03-03-2014, 04:10 PM
  2. Replies: 2
    Last Post: 08-19-2012, 06:15 AM
  3. Troubleshooting Please
    By jsking09 in forum C Programming
    Replies: 3
    Last Post: 03-03-2010, 02:37 AM
  4. how to improve my skills..
    By devil@work in forum C++ Programming
    Replies: 14
    Last Post: 04-08-2003, 02:13 PM
  5. Troubleshooting DDE
    By musicafterhours in forum Windows Programming
    Replies: 3
    Last Post: 11-18-2001, 08:26 AM