Thread: I can't spot my mistake...

  1. #151
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,088
    Fixed that segfault, turned I had poorly initialised a few variables in the process of moving core code, anyways I got closer to the correct behavior of FPN, addition, turned out I had to check the prior states of the exponents before deciding to add the assumed bit, also had to shorten the resulting mantissa length by 1 to ensure I got the overflow error upon those 2 bits being added, I used that error to detect when the final exponent should be incremented, now I've just got what appears to be an edge case and a buggy rotate right bitwise (either that or the width given to it is wrong, haven't seen possible causes of either yet)

    Code:
    make check.run
    ...
    Running suite(s): ALU
    ../tests/check_alu.c:966: test_alur_add_floating_fn() _num = 1, _val = 1, (EXP.upto = 63) - (EXP.from = 52) = 11, (MAN.upto = 52) - (MAN.from = 0) = 52
    ../tests/check_alu.c:977: test_alur_add_floating_fn() NUM = 0 +1023 11111111110 0000000000000000000000000000000000000000000000000000
    ../tests/check_alu.c:979: test_alur_add_floating_fn() NUM = 0 +0001 10000000000 0000000000000000000000000000000000000000000000000000
    99%: Checks: 1584, Failures: 1, Errors: 0
    ../tests/check_alu.c:981:F:Core:test_alur_add_floating:1: Assertion '1 == 0' failed
    ==11026==LeakSanitizer has encountered a fatal error.
    ==11026==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
    ==11026==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
    [Inferior 1 (process 11026) exited with code 01]
    (gdb) quit
    rm ../src/alu_int_d.o ../src/alu_math_d.o ../tests/check_alu_d.o ../src/alu_main_d.o ../src/alu_uint_d.o ../src/alu_fpn_d.o ../src/alu_bit_d.o ../src/alu_mem_d.o ../src/alu_vec_d.o
    Compilation finished successfully.
    I'll post code for the right shift in a minute, forgot to make alur__ror() rely on alup__ror()

    Edit: Apparently it was the alur__ror() that was buggy, dunno what I did there but making it rely on alup__ror() instead got rid of the right shift errors so I'll ignore that one. I've replaced the above output with the fresh output, as you can see it is only 1 addition left that is resulting in the incorrect exponent, since I'm once again drawing a blank I'll leave it at that after uploading the change I just made, hopefully either I or someone else gets an idea for fixing that while I'm moving more code into the alup_* functions
    Last edited by awsdert; 1 Day Ago at 11:20 AM.

  2. #152
    Registered User
    Join Date
    Sep 2020
    Posts
    77
    I find it interesting that you don't see compile errors when using uninitialized variables, even though warnings are turned on.

    I haven't bothered investigating why that would be... can you think of any reason?

  3. #153
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,088
    Quote Originally Posted by hamster_nz View Post
    I find it interesting that you don't see compile errors when using uninitialized variables, even though warnings are turned on.

    I haven't bothered investigating why that would be... can you think of any reason?
    Because I initialise them before I use them, it only kicks up a fuss when there is no sign of it being initialised at all before the attempt to use the information it has

    Here's an example:
    Code:
    int ret;
    return ret; // Error flagged here
    Code:
    int ret;
    foo(&ret);
    return ret; // No error because foo is now seen as responsible for initialisation
    Edit: Another example:
    Code:
    int ret;
    ret = foo();
    return ret; // No error because it was initialised with the result of foo()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can anyone help to spot mistake in the code
    By chess_queen in forum C Programming
    Replies: 1
    Last Post: 10-21-2012, 10:37 AM
  2. Can you spot my mistake?
    By Brewer in forum C Programming
    Replies: 13
    Last Post: 11-12-2006, 12:50 PM
  3. going to a certain spot in a file...
    By agerealm in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2002, 02:31 AM

Tags for this Thread