« first day (1319 days earlier)      last day (1517 days later) » 

nwp
8:31 AM
@SAJW Also using .at(i) instead of [i] is an option.
Also ASan should catch it.
 
 
3 hours later…
12:01 PM
I am observing g++ preprocessor removes empty lines and covert Tabs into spaces on the Linux platform whereas on the Windows platform it not be able to do the same. Can anyone please help me how to this can be achieved on Windows platform or how can I stop g++ to stop removing the lines
 
12:19 PM
why do you care about the preprocessed output?
 
 
2 hours later…
2:33 PM
I was surprised that my compiler (GNU GCC) can devide by zero, while learning about throwing and catching exceptions.
 
@SAJW really? it's undefined behavior
 
well it says inf as the result so i guess it is defined
 
nwp
That's not a good guess.
 
pastebin.com/p2HVqWni if you run this and type 0 as divisor you get inf as the quotient, mmh.
 
nwp
Let me rephrase. "X happens so it must be defined that X happens" is not a good way of figuring out the rules.
Sometimes the rule says "Do whatever" and your logic fails to discover that.
 
2:39 PM
@SAJW oh floating point... that should return NaN IIRC
 
nwp
I looked something up and apparently positive/0. makes inf, negative/0. makes -inf and 0/0. makes NaN.
 
cute
 
@nwp should I throw an exception inside the quotient function and catch it inside the main in a try-block? (something like: Oops, you devided by zero!)
 
nwp
division is poorly named and should be deleted.
And I don't think you should do any error handling. The IEEE behavior seems reasonable.
 
@SAJW if you absolutely must do anything use the standard but in general... don't bother?
it's worth noting that this is a bad idea in general
 
3:06 PM
@Mgetz ok, then I don't bother!
 
 
2 hours later…
5:11 PM
I tried to use a try-block but it doesn't catch the right exception but writes the general exception block.
Here the code: https://pastebin.com/G2pPX9wc enter -1 or 101 as age to see what i mean.
What did I do wrong?
 
 
1 hour later…
6:39 PM
@SAJW you're not throwing std::exception you're throwing char
 
@Mgetz not "char*"?
 
@SAJW no definitely char not char*
 
ah ok
should every catch-block throw too? I guess definitively
 
@SAJW wut
 
6:54 PM
try
{
    int a=3;
    int b=0;
    if (b==0)
    {
        throw 'e';
    }
    int c=a/b;
    std::cout << c << "\n";
}
catch (const char msg)
{
    std::cout << "Error occured " << msg << "\n";
    throw;
}
is the throw in the catch-block unneccessary?
 
@SAJW if something is expected to fail often using exception is usually a bad idea
FWIW most compilers would just optimize that entire thing to the catch block
since B is guaranteed to be zero
also integer divide by zero is undefined
in most systems however it triggers a fault
 
 
2 hours later…
9:28 PM
In a while loop I have multiple conditions but one shouldn't be checked if the prior conditions are not met. Otherwise an error is thrown.
`while(!a.b() && c != d && c != e && (foo(a) >= foo(c))` how do you make it so foo isn't called if the previous conditions aren't met?
 
9:47 PM
Put simpler how would you fix while(foo1() && foo2()) where foo2() should never be checked if foo1() returns false?
 
10:37 PM
@northerner I don't undestand isn't that just how "&&" already works? if foo1() reuturns false then the expression evaluates to false without calling foo2()
 

« first day (1319 days earlier)      last day (1517 days later) »