« first day (539 days earlier)      last day (4402 days later) » 

9:03 PM
I would rewrite the logic. Or perhaps throw std::logic_error..
// something like this..
void getResourceLifetime() {
    // requires ugly macro
    LOCK(Resource & resource, GetResource()) {
        return resource.getLifeTime();
    }
    throw; // compiler-happy
}
 
You can throw; outside of catch?
 
AFAIK yes.
 
What does it throw?
 
I guess it throws ...
 
Are you trolling me?
@StackedCrooked You didn't have the "run" checkbox marked.
ideone doesn't compile if you don't do that.
 
It always compiled for me back in the days when I didn't understand exceptions…
 
I guess I'll throw logic_error.
 
@RMartinhoFernandes Actually, I never really thought about it. Could be invalid C++ even though it compiles.
 
Never thought I'd make use of that.
 
You never use logic_error?
 
9:11 PM
No.
If there's a bug, I'd rather fix it instead of throwing an exception.
I mean, I can't really think of a situation that warrants throwing it. In this case I think it's okay because it's dead code.
 
I sometimes use logic error to report invalid arguments.
 
Isn't there a more appropriate one?
 
invalid_argument :D
But it inherits logic_error.
 
That's stupid.
 
9:14 PM
It's a programmer error, not a logic error.
 
Hi
 
@daknok_t What's the difference?
In my view, programmer error = bug = logic error.
@kbok Hi.
 
Is this the place for being an asshole?
 
In my view, programmer errors are passing invalid arguments for example, glBegin(); glMatrixMode(...);. Things that happen by not reading the documentation.
 
@Pubby This is the place for anything that can entertain us.
 
9:17 PM
I was wondering
Why is this a pointer and not a reference ?
 
Historical reasons.
@daknok_t Violation of preconditions is what logic_error is for.
 
@kbok You can Google that exact sentence :)
 
this is older than references.
 
And I guess that's why invalid_argument is a subclass of logic_error.
 
@StackedCrooked Oh. :)
 
9:21 PM
Hmm, #define this (*this)
 
Don't.
 
#define self (*this) if you want.
Still dangerous though.
 
That's better at least (as long as you don't use boost.spirit.lex or Objective-C++).
 
Hi all! Gonna chickie-picky! :)
 
Macros are always problematic.
 
9:22 PM
Macros are awesome... :D
 
The general rule is: don't define macros without prefixing them with your project name, unless you're me.
That should cause grief to no one.
:P
 
Like this article:
C malloc and free vs C++ new and delete
 
Qt :P
 
@RMartinhoFernandes why neither? :)
 
9:27 PM
Robot uses mmap and likes it
 
Who?
 
@daknok_t Martinho maybe
 
I have my own kernel module that exposes direct access to the page directories.
(I have no idea if that is even possible)
 
Kernel module? I thought all your code ran in kernel mode.
 
@user1131997 Because the article doesn't mention RAII at all
Any C++ tutorial or book that doesn't teach RAII is garbage.
 
9:32 PM
@Pubby how is better to name ring2 in Windows family? it's neither kernel nor usermode :)
@Insilico ah! thank you very much with advice!
 
@user1131997 Rings have more to do with computer security than OS architecture.
 
I thought x86 OSes only used rings 0 and 3.
 
@RMartinhoFernandes then when launchs Native API of Windows?
 
Because SYSENTER and friends use that. Or something.
 
My understanding was that the kernel <--> application distinction is orthogonal to the ring levels
 
9:34 PM
@RMartinhoFernandes It's not WinAPI, and doen't work at Win32 environment
 
it's called Native API exact
here is info
The Native API (with capitalized N) is the mostly undocumented application programming interface used internally by the Windows NT family of operating systems produced by Microsoft. It is predominately used during system boot, when other components of Windows are unavailable. The Program Entry point is called DriverEntry(), the same as for a Windows Device Driver. However, the application runs in Ring 3 the same as a regular Windows Application. Most of the Native API calls are implemented in ntoskrnl.exe and are exposed to user mode by ntdll.dll. Some Native API calls are implemented in us...
many *.sys drivers work with Native API
 
What about it?
 
in ring2
in Windows
 
Read again.
> However, the application runs in Ring 3 the same as a regular Windows Application.
It's right there in the box.
 
9:36 PM
ah, it's wiki
wait
shall find in msdn
 
Really, switching to rings 1 and 2 in x86 is complicated enough to make it not worth at all.
 
Again, the kernel/app distinction in OSes are different from ring levels
How they correspond to each other is not standard
 
@Insilico We're talking specifically about Windows :)
 
In computer science, hierarchical protection domains, often called protection rings, are mechanisms to protect data and functionality from faults (fault tolerance) and malicious behaviour (computer security). This approach is diametrically opposite to that of capability-based security. Computer operating systems provide different levels of access to resources. A protection ring is one of two or more hierarchical levels or layers of privilege within the architecture of a computer system. This is generally hardware-enforced by some CPU architectures that provide different CPU modes at t...
> However, most general-purpose systems use only two rings, even if the hardware they run on provides more CPU modes than that. For example, Windows XP and below only uses two rings, with ring 0 corresponding to kernel mode and ring 3 to user mode.[3]
 
ring 0 for kernel code and device drivers, ring 2 for privileged code (user programs with I/O access permissions), and ring 3 for unprivileged code (nearly all user programs). Under DOS, the kernel, drivers and applications typically run on ring 3, whereas 386 memory managers such as EMM386 run at ring 0. In addition to this, DR-DOS' EMM386 3.xx can optionally run some modules (such as DPMS) on ring 1 instead.
 
9:40 PM
So? You're just proving my point
 
@user1131997 Where does that mention Windows?
 
> the kernel/app distinction in OSes are different from ring levels
 
@RMartinhoFernandes f*ck, I'm really confuse smth :(
When I read about KMDF/UMDF , I thought , that KMDF was launched in ring2 as wrapper between ring0 & ring3 to send to data to UMDF
*kernet/user mode development foundation
 
Where does it say that?
 
@Insilico No where , indeed :( I have confused :((((
sorry
 
9:45 PM
Oh okay
 
Windows uses only two rings for compatibility with other architectures.
Remember that NT once supported Alpha and things like that, and recently they've gone to ARM.
 
@CatPlusPlus WinCE ?
 
No, Win8.
 
@user1131997: They've been talking about ARM for a long time
 
The point is NT was designed to be cross-platform.
So they've settled on two rings as the greatest common denominator.
 
9:48 PM
What's product Windows Embedded? Is it WinCE?
Can I install WinEmb on my x86 pc?
or VM like VBox?
 
Microsoft Windows CE (now officially known as Windows Embedded Compact and previously also known as Windows Embedded CE , and sometimes abbreviated WinCE) is an operating system developed by Microsoft for embedded systems. Windows CE is a distinct operating system and kernel, rather than a trimmed-down version of desktop Windows. It is not to be confused with Windows Embedded Standard which is an NT-based componentized version of desktop Microsoft Windows. Microsoft licenses Windows CE to OEMs and device makers. The OEMs and device makers can modify and create their own user interfaces a...
> The current version of Windows Embedded Compact supports Intel x86 and compatibles, MIPS, and ARM processors.
 
@CatPlusPlus Lowest, you mean.
 
Maybe. You know what I mean.
 
sbi
10:11 PM
This guy flies low. And I mean, really low. Less than a meter above the ground, they say. I currently cannot find it, but I have seen the same thing from the cockpit's POV somewhere, and you can see how his comrades fling themselves to the ground, in order to not to get hit.
 
Can't YouTube with this connection.
>  ¡¡¡¡¡¡ motherfucker is you fucking bastard !!!!!!!!!!!
Ah, traditional YouTube comments.
 
sbi
@RMartinhoFernandes Not even 34secs at 240p?
 
Took forever to load.
 
@sbi Lo. Did you ever learn to use Expression Trees?
 
Xeo
@RMartinhoFernandes declare_unreachable?
 
10:22 PM
@Xeo That's for garbage collection.
I don't see how it helps.
 
Xeo
Eh, I meant that unreachable thingy-declspec-blah
 
Expression trees are awesome.
 
sbi
@LewsTherin I once wrote an expression template thingumy. It creates expression trees, and evaluates them, at compile-time. Does that count?
 
@sbi Oh I wasn't aware of another sbi ;) Couldn't resist..
@RMartinhoFernandes Lol is there anything you can't do? :P
I need a good book to learn how to use it
 
@Xeo Don't know if GCC has anything like that.
@LewsTherin I assume you're talking about .NET expression trees, right? I've been using C# since ever.
 
Xeo
10:25 PM
__builtin_unreachable();
 
@RMartinhoFernandes Yeah exactly that :) It sounds really cool. I want to know about it
 
Xeo
> If control flow reaches the point of the __builtin_unreachable, the program is undefined. It is useful in situations where the compiler cannot deduce the unreachability of the code.
 
@sbi Really?
I guess so then
 
sbi
@LewsTherin No, I'm just kidding. SCNR.
 
10:27 PM
What books did you guys use?
@sbi Touche.
 
WTF, clang defines __GNUC__?
 
Xeo
huh?
 
sbi
@LewsTherin Expression templates I learned from Todd's original article from the 90s. Josuttis/Vandervorde's template book has a pretty good description of them, though.
 
@sbi What? Been around that long? Omg thought it was new stuff
 
How can I reliably distinguish between clang and GCC then?
@LewsTherin Expression templates are C++.
 
Xeo
10:29 PM
__CLANG__? (or whatever that was)
 
@Xeo Apparently it poses as GCC 4.2.1
 
it's ` __clang__`
 
@RMartinhoFernandes Expression Trees.. unless they are the same thing?
 
sbi
@LewsTherin Expression templates?
 
@sbi You have a link?
 
10:30 PM
markdown sucks
 
sbi
> The technique was proposed by Todd Veldhuizen in his June 1995 article in the C++ Report. — Wikipedia
 
@rubenvb Argh, but now I need defined(__GNUC__) && !defined(__clang__) to detect GCC.
Why the heck does clang pose as GCC 4.2.1?
 
@sbi I don't know what that is
 
@RMartinhoFernandes yes
 
Xeo
I would say that's a bug, if it does
 
sbi
10:31 PM
@LewsTherin I dunno what .NET considers expression trees, but the general term, I thought, refers to expressions being stored in trees. Expression templates do just that — but at compile time. It's one of the two roots of template meta programming.
 
@RMartinhoFernandes cause it really qualifies as GC 4.2.1. They made it fully compatible with that version, to ease MAC dev's transition to Clang
 
sbi
@LewsTherin I even linked to it.
 
@sbi Thanks.. so all that metaprogramming this is what it is? Wow..
 
sbi
Here's a copy of Todd's original paper.
 
I remember asking @RMartinhoFernandes how he can add 2 numbers at compile time.. is this somewhat related?
 
Xeo
10:32 PM
Expression templates are not template metaprogramming. They're far from related.
 
Because of that compiling this with clang was really messed up.
 
sbi
@LewsTherin I got a parse error on that sentence. If it is a sentence...
@Xeo What? Have you been smoking something? Shall I call your mother and tell?
 
I was #defineing keywords and shit.
Oh, screw it. I forgot clang doesn't SFINAE properly.
 
@sbi It is.
 
Let's stick to GCC some more...
 
10:35 PM
I jst discovered the stock Android rom I'm flashing has a buggy browser that crashes on certain javascript stuffs like when loading xda-developers.com
which sucks ass
 
Xeo
@sbi Well, atleast I wouldn't really call them related. TMP is pure compile time. Expr Templates are more about (effects on) runtime, imo.
And they serve different purposes. Unless I really misunderstood something
 
What's your definition of TMP?
(Everyone seems to have one)
 
sbi
@Xeo That's not one of the definitions for TMP I have seen. The ones I have seen even include juggling with function templates.
 
As soon as you it involves computation with types, I call it TMP.
Expression templates do.
 
Xeo
@RMartinhoFernandes Type transformations and computations at compile time.
 
sbi
10:37 PM
@RMartinhoFernandes What about values, rather than types?
 
I just got lost.. but it seems Expression Templates might be a start to learning ETrees
 
@sbi Ah, that's not as practical, but yeah, it counts too.
 
sbi
@LewsTherin ET does mean Expression Templates. At least it does so here, in the C++ room.
 
@Xeo And expression templates involve building the optimal types at compile time.
 
sbi
@RMartinhoFernandes Well, the moment I typed that I thought that, in order to do anything useful with values in TMP, they are usually typified anyway.
 
Xeo
10:39 PM
Well, okay. But I just can't see expression templates as TMP.
 
sbi
@Xeo Does building expressions trees count as "computation"?
 
@RMartinhoFernandes what's wrong with clang and sfinae?
 
sbi
@Xeo Then you might want to consider talking to an optometrist.
 
Xeo
A what?
 
10:40 PM
@rubenvb Clang doesn't SFINAE with aliases. Since I use an EnableIf alias all over, it just spews gazillions of errors.
 
sbi
@Xeo Optiker.
 
@Xeo :O
 
@Xeo An eye doctor.
 
Xeo
Okay, guessed as much
 
@RMartinhoFernandes I hope you reported a bug?
 
sbi
10:41 PM
@RMartinhoFernandes "Eye doctor" sounds like it's part of Steve Jobs' legacy.
 
Xeo
@LewsTherin Sorry that I don't know all technical terms in English. :P
 
@Xeo No need to apologize :)
 
@rubenvb I haven't yet confirmed if the standard requires that to work (but if it doesn't, fuck the standard, I want GCC's behaviour).
 
lol, a decent feature request might spark the interest if it's not too difficult to maintain in Clang.
 
Xeo
@RMartinhoFernandes What exactly?
 
10:50 PM
9 mins ago, by R. Martinho Fernandes
@rubenvb Clang doesn't SFINAE with aliases. Since I use an EnableIf alias all over, it just spews gazillions of errors.
template <typename T, EnableIf<std::is_pointer<T>> = {}>
void f();
template <typename T, EnableIf<Not<std::is_pointer<T>>> = {}>
void f();
f<int*>(); // fails because clang doesn't SFINAE across template aliases
 
Xeo
try template<class T, class = EnableIf<std::is_pointer<T>>>?
Also, creating a void with {}? Or does your EnableIf alias have another type if it succeeds?
 
@Xeo Not a void, it's an enum.
@Xeo I don't want that!
 
Xeo
k
 
That looks uglier.
:P
 
Xeo
I don't think so
 
10:54 PM
(But I have to try)
 
Hi all!
 
Xeo
I think yours is uglier because enable_if defaults to void, which doesn't make sense with your form
 
Could someone help me? I have a trouble about operator ? :
 
@Xeo Well, it's not the uglies (I was joking). Mine works everywhere.
typename = requires me to add a dummy parameter on the other overload.
 
It's possibile to put more than one instruction in each part of the operator?
 
10:55 PM
And an extra dummy for each subsequent overload.
And that does get uglier.
 
sbi
Sometimes I wonder how you guys can stand talking about C++ all day. Then I remember I'm in the C++ room.
 
@Xeo EnableIf doesn't provide return values. What it defaults to is irrelevant there.
 
sbi
room topic changed to Lounge<C++>: We haven't said anything noteworthy in hours. [c++] [c++11] [c++-faq]
 
Xeo
@RMartinhoFernandes Shouldn't that be exactly the same as your alias version?
room topic changed to Lounge<C++>: Beware of wild C++. [c++] [c++11] [c++-faq]
 
@Xeo No. Mine doesn't generate a proper template signature (whatever that is called) if substitution fails.
 
Xeo
11:00 PM
Erm.. I don't see how the non-alias version would? It should be exactly the same.
 
Please, someone could help me?
 
It's either <typename, magic_enabler_type> or nothing. The typename = one generates <typename, typename> for both overloads, and that's why I need the dummy.
template <typename T, typename = EnableIf<true>>
void f();
template <typename T, typename = EnableIf<false>>
void f(); // ERROR: same template, different default params? Nope.
template <typename T, typename = EnableIf<true>>
void f();
template <typename T, typename = EnableIf<false>, typename = void> // dummy makes it a different template
void f();
 
Xeo
Ah, I see now. Blame my hazy brain after a few too many hours of being awake. But I still don't see why a substitution failure even creates a <class, class> sig
 
@Xeo Because that's available on the first phase.
Before specialization.
 
Xeo
Oh, okay
Okay, then forget all my complaints :)
 
11:17 PM
No one can help me?
 
@unNaturhal Why can't you use an if?
 
I'm trying, as exercise, to make my code unreadable
 
@unNaturhal What??
 
@LewsTherin: ? What you haven't understood?
 
11:24 PM
@unNaturhal Just asked that in disbelief.. why??
 
Ah! LOL
Have you ever seen the 404 page of stackoverflow.com? xD
 
It's polyglot.
It outputs 404 and compiles in 4 different languages.
 
Yeah, but it's really unreadable
#define v putchar
#define print(x) main(){v(4+v(v(52)-4)); return 0;} /*
#>+++++++4+[>++++++<-]>++++.----.++++*/
print(202*2);exit();
#define/*>.@*/exit()
 
Yeah..so can't read that
 
It's C, sh, brainfuck and Befunge, I think.
 
11:28 PM
I'm trying to obtain somthing similar, as exercise, and as riddle..
Befunge? Another esoteric programming language?
 
Get whitespace or somethng
 
@unNaturhal Yes.
It's two-dimensional. The >, <, ^, and v change the direction of execution of code.
That's why there's the #define v putchar on top :)
 
Wow.. amazing :O
 
Sure...
 
Xeo
62
Q: What's the joke in the Stack Overflow 404 page code?

DexterI have journeyed thus and bruised into the lands of the error page on Stack Overflow. There, upon the sight on the hill I see a vision as such: For those reading with images off: # define v putchar # define print(x) main(){v(4+v(v(52)-4));return 0;}/* #>+++++++4+[>++++++<-]> +++...

 
11:31 PM
But I don't need that my code is polyglot, it's enough that is unreadable :P
Mmmmh... why 404 code compiles without #include <cstdlib>?
 
@unNaturhal What is the point? You will never write unreadable code in the real world.. :I
 
Xeo
9
A: What's the joke in the Stack Overflow 404 page code?

d_r_wHere's my shot at a 404. It's not a polyglot, but it's more visually interesting: #define _ f++>o--*ur-- || o--*h++ || f++*o--*ur; int f = 0, o = 0, ur = 0, h = 0; main(){f++;o--*ur;o--*h;f*our();printf("%d\n", (f-o-ur));}/*oh, f*/our(){ _-_ _-_ _-_ _-_ _-_ _-_ _-_ -...

@unNaturhal putchar is usable without it. And it's C.
there's only <stdlib.h> in C
 
@LewsTherin: I know that my code should be always readable. But I think that writing unreadable cose could be consider as a skill, and it's funny to suggest to you friend as joke :P
 
@unNaturhal Writing unreadable should be very easy imo. Writing readable code.. now that is the difficult part lol.
If you have mastered it.. no problem then :D
 
Ahahhahah
 
11:38 PM
Do you know of the IOCCC?
That should provide enough inspiration.
 
Xeo
@LewsTherin Not only readably, but also clear code. Code that explains what it does with just a look.
@RMartinhoFernandes I love the circle Pi approximator one
 
@RMartinhoFernandes: Wow! Great!
 
@Xeo Yeah! It should be as if reading English.
 
Ok, I think to have used the wrong word. It's not "unreadable" but "obfuscated"!
If ternary operator allows to use more than one istruction per side, I reached my goal...
 
@unNaturhal Does it not do that already? Or I don't understand.. with the ,
 
11:46 PM
@unNaturhal The comma operator is your friend.
 
Comma operator?
However, I wanna do something like:
condition ? (operation1; operation2) : operation3;
 
condition ? (operation1, operation2) : operation3 should work, provided the operations are not loops or something.
 
Are function invocations
 
Should work fine then.
 
Shouldn't be different should it?
 
11:50 PM
...it doesn't :(
 
here:
        (z[i] != 46) ? putchar((char)z[i--]), goto here : purchar((char)46);
Compiler give me:
expected expression before 'goto'
 
Ah goto.. Jesus
 
Ahahahah
 
That's one quick way of writing unreadable code I guess
 
11:52 PM
@unNaturhal Ah, goto is a statement. Only expressions are allowed there :)
 
@LewsTherin Yeah! I know xD Before than today I do not even know the goto syntax xD
@RMartinhoFernandes Damn! :/
Any help?
 
There's no way around that.
Can't put goto in ?:.
 
Not even if it's alone? Leaving the first putchar
 
Damn...
 
11:55 PM
goto here doesn't have a value.
 
:/
Ok, I have to find another way xD
 
@unNaturhal I still don't know how to use it.. I hope never.
 
@LewsTherin In this case it's useful :P
 
Aaaaaaaaaaaggh :D
 
Do you want to help me to make my code obfuscated?
It's funny (I find it funny.. maybe I'm foolish)
 
11:59 PM
@unNaturhal Not that smart, thanks though.
 

« first day (539 days earlier)      last day (4402 days later) »