« first day (33 days earlier)      last day (26 days later) » 
00:00 - 22:0022:00 - 00:00

12:45 AM
helo, i need someone to help me out with a c project tht im making, it has an array issue. anyone?
 
1 message moved from Lounge<C++>
@Questionare232 so, is it a big array? Or were you never going to be more specific
 
yes, its very big, and code is 2000+ lines
 
So, it's not really an array issue then. Why don't you ask on Stack Overflow? Perhaps with something more tangible than "array issue in 2000+ lines"?
 
im pretty sure its an array issue n the code cant fit bcuz of a word limit
 
1:02 AM
@sehe - hey, how goes the new job?
 
@Questionare232 I can't help but notice you can hardly type a full sentence. I can reassure you there is no limit on chat messages (well, not that low anyways) :)
@BryanEdds Ups and downs. I'll get there. Case of the head aches right now
 
hm yes, sounds familiar :)
 
ok, so what ur saying is that i should post my code here? :x
 
I'm saying you can't expect anyone to understand without seeing anything. There's sites for sharing files. pastebin, gist whatnot
 
woah kool, ok link: pastebin.com/vGguwZVJ
There is a problem with the inventory.spoiltquantity variable, when i run the cash register it copies the quantity and what its sposed to do is only display the quantity of items discarded not sold..
 
1:13 AM
Hi, has anyone here worked with libctags?
 
@edition I've seen enough of it
@Questionare232 fix this at least
         if (choice == 6) {
            choice == 0; // should be choice = 0
            break;
        }
 
@sehe I'm trying to create a C++ parser with support for additional keywords using libctags, but it won't compile on Windows.
 
@edition ew :) ctags "parser" (misnomer of the year) and Windows ...
 
oh right, what line?
 
@sehe yes, I know. Is there a smaller but complete C++ parser?
 
1:17 AM
@Questionare232 You know how to handle an editor, right
@edition Smaller than what? AFAIR libctags doesn't "parse" at all. It's all glorified regexen
 
yea.. nvm just used search n found it
 
@Questionare232 That's a huge pile of oldfashioned C code. Is your course teaching C? (why...)
 
user5711741
Hi
 
xD old fashioned? Lol, no not teaching it, still in school
 
All those global variables... Ugh. There's very little that makes this code amenable to review
 
1:20 AM
@sehe in other words, what can I use to parse and produce an AST for C++ code?
 
libclang is the defacto library for that
@Questionare232 scanf("%s", inventory.stock[a]); is undefined behaviour. Can't store a c string in a float
Same for scanf("%s", inventory.sold[a]);
All those sleep() calls. Are they there to annoy the user?
 
@sehe thanks. libclang has a lot of documentation to navigate through, but I'll figure it out.
 
Some loungers have used ti
    sleep(3);
    printf("This program is optimized for Fullscreen mode.\n    Press 'alt + enter' to go Fullscreen.\n\n\n");
    sleep(2);
    printf("Program will now load. Please be patient..");
    sleep(3);
Awesome. I remember seeing code like that in ~1990
 
huh.. didnt even see those, dont even kno why does it compile.. the sleeping is jus to make it look a bit more professional
ohh kl
 
@Questionare232 try enabling warnings...
 
1:31 AM
i think those are enabled in dev c++ by default if im not mistaken..
 
You're clearly mistaken
So is this a C class? or a C++ class?
 
in the console it says zero warnings though so thats why i say that n its jus a standard c class
 
consider using full words so it's easier possible to understand you
   while (floatcontainer > inventory.stock[z]) {
 
ohhh ok sorry, force of habbit.
 
This goes out of bounds. z goes to 10000
30 mins ago, by Questionare232
woah kool, ok link: http://pastebin.com/vGguwZVJ
@BryanEdds what do you say, is it too early to call that "unprovoked abuse"?
 
1:42 AM
hehe
I really need to write up more succinct rules on how to format a question for here
 
I'm sorry to say it, but the code doesn't invite much constructive criticism
 
so this is really my fault
 
It's actually the fault of teachers teaching bad programming languages in worse ways
 
well, you know the adage - those who can't do it, teach it!
 
ohh ok.. You can't find the issue?
 
1:46 AM
the haystack is too big to go looking for needles
 
its probably how i was taught the syntax of c that caused it
i see
 
you have to reduce your code sample to something that people can quickly analyze
 
@Questionare232 I can. I just won't. You can't pay me enough. I'm sorry. A little bit. I wish I could tell your teacher how much harm they're causing
3
@Questionare232 You didn't actually describe the "issue" either
 
again, my fault - I need to write a couple new rules that describe how to ask questions productively here
 
ok no problem, it won't matter but here is the issue anyways. The issue is that the the inventory.spoiltquantity variable is supposed to only show the quantity of the item that is disposed but when I run the cashregister, the amount sold is copied to the spoiltquantity for some reason that i have spent hours looking for
well thanks for your time
 
1:53 AM
@Questionare232 I can only offer the overwhelming likelihood of Undefined Behaviour. You'd need to at least provide the input to reproduce the behaviour.
 
 
13 hours later…
3:03 PM
Lots of work on my new C++ core library, Ax - github.com/bryanedds/ax
@sehe - I clean up a lot of naming as you suggested, tho some of the names are still a bit longish, perhaps due to my lingering paranoia about C++ resolution rules.
@sehe - hope you can get around to tackling the UB when you get a chance :)
 
3:41 PM
@BryanEdds oh yeah, by all means, use proper namespaces and un-ADL-sensitive names (prolly best to not name all your functions get and swap). But beyond that, namespaces are your friend. It looks much lighter already
@BryanEdds It's on the list. But head aches are plaguing me. So, likely weekend it's gonna be
 
no worries - I appreciate it's on anyone's list at all :)
C++14 finally gives me sufficient confidence to write code in C++ - it is such a big difference!
I mean, I wrote C++ code before, but never with any real confidence
reliable program semantics and memory safety are chief concerns to me, and C++14 almost entirely provides that
there is one memory-safety issue that I might bicker about at some point, but it concerns memory in the stack, so it's not quite as concerning to me
 
@BryanEdds That's a good thing and a bad thing.
It's true that c++14 allows you to focus on more highlevel things. The caveat is that things are not actually any safer
 
the example is taking a const ref of a value getted from another const ref that happened to be a temporary -
 
Yup. The problem there is that all these const& are usually premature optimizations
 
by the time the const ref is assigned, the containing temporary is gone
 
3:52 PM
Of course, good library code /had/ (has?) to make those, but it takes discipline to know which refs you can hold on to
 
r u srs rn
This is just bad
 
I tried to convince my team that a lot were premature optimizations, but got waylaid
 
The whole point of CXX and CC is to inherit them from the env
 
@BryanEdds And they used to be right(ish)
 
heh - talk to @sehe - he wrote them :)
 
3:53 PM
Anyhoops. The real solution is GSLS/CppCodingGuidelines
@набиячлэвэлиь Depends on the goal, mr
 
> >implying I'm a "mr"
 
I just whipped up a Makefile because the library author had neglected any non-MSVC platform.
Aaaand I wanted to be able to switch compilers at leisure.
 
I don't know how to write makefiles
 
@набиячлэвэлиь You deserve it
 
try to be a little nicer, eh @набиячлэвэлиь?
you hurtz my fee fees sometime :(
 
3:55 PM
Hehe. He can't be any nicer :)
 
anyway, ya, I suck at this stuff, but I hope to improve it over time
 
@набиячлэвэлиь /cc @BryanEdds that CXX could likely be removed/commented yes
 
that being said, I can't get clang to compile the project with that makefile, so I instead did this -
yes I know I'm a bad person
 
> -Wno-vexing-parse
WHO ON EARTH DOES THAT
Finally, we get sane compilers with useful diagnostics. And people ... disable them?
 
that's generally useful when writing generic code, no?
 
4:01 PM
Of course not.
 
hmm... maybe that can be taken out now after some of the clean up I did
 
Vexing parse is vexing parse. You want to be explicit. Use {}
 
ya, I actually changed code to use {} a lot more
so I think I can remove that
 
The other component that plays into this is: don't shadow types with variable names.
 
that I'm less willing to compromise on
 
4:02 PM
It's simple. If you want to use the same names, don't using namespace, so ns::thing is the type, and thing can be your variable
 
I don't use using anywhere
well, not that form of it
 
@BryanEdds It's not a compromise. It's priorities. Value correctness. Style or "familiarity" is a secondary concern
 
@sehe Lol.
Why would someone do that.
 
@BryanEdds well, don't using ns::thing then
 
I don't
I think we're talking about something different
 
4:03 PM
Ok. That used to be the problem with all these name shadowing problems.
 
I remember you used _ for some member names, then I removed them and there were no issues
not sure why you added them?
a var should be able to have the same name as a type, and in the context of the namespace definition, will shadow
 
Oh, and those glorious unconditional #pragma disables
 
@BryanEdds Nah. You're talking about vexing parse and I mention name shadowing which plays into this. The compiler, when seeing int something(thing); can see a MVP iff thing is a variable that happens to alias a type.
 
which is acceptable, imo
 
@BryanEdds because code that compiles is better than code that does not
@набиячлэвэлиь I've seen pops (restore?) too IIRC
 
4:07 PM
@набиячлэвэлиь - I'm pretty sure all pragma disableds are conditional now
 
// Variable shadowing is a good thing when doing functional-style programming.
#if defined(_WIN32)
    #pragma warning(disable: 4456)
#endif
No, they aren't
Or, well, they are, but on the wrong macro
 
yes they are
 
Should be something along the lines of _MSVC_VER
 
well again, blame @sehe :)
he was just trying to get things working on gcc and clang
@набиячлэвэлиь I'd like to know what makes you an authority on functional programming.
I truly think you're speaking out of ignorance on the shadowing issue.
 
I'm no authority on "functional programming", nah. Go to mr. Odersky for that
@BryanEdds No, read again.
2 mins ago, by набиячлэвэлиь
Or, well, they are, but on the wrong macro
2 mins ago, by набиячлэвэлиь
Should be something along the lines of _MSVC_VER
 
4:10 PM
well, now I've lost the plot
 
_WIN32 doesn't entail _MSC_VER
 
we're talking about so many issues at once, hard to tell
_MSC_VER
(saw that in a header library I pulled in)
(easy enough to fix)
I'm fixing these issues, just have a little patience while I pop them in :)
 
Is it just me or is #defineing var and val a horrible idea?
 
some people will argue that, yes
 
@BryanEdds I'm getting loadsa errors from stdlib functions caused by their usage of var and val as verbol names and their apparent inclusion after the #defineition
 
4:18 PM
why are you including prelude headers before stdlib headers?
 
I'm compiling upstream rn
Well, trying to
I'd go for VAR or the less obstructive var_ or _var
 
i may be forced to do that
hmm... what about Var?
capitalized
 
kind of an ugly situation, but I feel we solved most of my other problems well enough to permit some ugliness here and there
but yes, absolutely everything should compile find in MSVC, gcc, and clang in the repo, so I'm not sure what issue you're having, @набиячлэвэлиь
 
Different stdlib, probably
 
4:23 PM
using libstd++?
 
No, libstdc++, probably. Whatever ships with GCC by default
 
strange - I'm using the same stdlib afaik
what version of gcc?
 
> g++ (Rev1, Built by MSYS2 project) 5.3.0
 
hm, newer than mine
actually, mine's somewhat old
@набиячлэвэлиь - I can tell you why -Wno-vexing-parse is in there for clang -
// Assert a type constraint.
#define constrain(type, constraint_name) \
    typename type::constraint_name##_constraint assert_constraint_fn(); \
    (void)&assert_constraint_fn
it interprets typename type::constraint_name##_constraint assert_constraint_fn() as a vexing parse when it is not.
it's supposed to be a function declaration.
altho, perhaps the general approach for the macro is wrong, but the warning really is misinterpreting my intent
 
4:38 PM
@sehe You really feel that way?
@BryanEdds So that headers have to be self-sufficient.
 
@caps - not sure what we're talking about?
afaik, they are self-sufficient
 
for file in $(busybox find -type f); do cat $file > temp && cat temp | perl -pe 's/va([lr][^[:alnum:]])/Va\1/g' > $file && echo $file; done
 
that fixed it?
 
I'm running that now
let's see
 
if so, I'll do the refactoring here via VS and commit
(i hate these little ugly compromises :/)
 
4:46 PM
I somehow feel my regex-based refucktor more reliable than an automated one in this particular case
Yep, it works
Lemme submit a patch
 
ty sir - working on now
hmm - capitalization doesn't look too bad...
somehow missed a few, but I got them
(you were a couple commits behind)
 
Yep, I merged in your six new commits
 
ok, all fixed in latest
definitely good that was fixed - can't rely on ax headers not coming before std headers
still, kinda ugly... :(
many compromises must be made however
welcome back, to the stage of history
better
 
5:16 PM
Good news, @Bryan! It compiles warninglessly, bar the offsetof-induced UB warnings
 
cool man :)
going to be interesting once Uniform Call Syntax lands
i may not be able to leverage it, however, since I think I will try to keep the repo compatible with C++14
 
What'cha think, about this Makefile, @BryanEdds?
 
I'll try running it locally
 
Having TravisCI enabled for that repo would help
 
hm ya
 
5:26 PM
@BryanEdds What's your GCC version?
 
gcc version 4.9.3 (GCC)
 
Okay, let's try testing that TravisCI on my fork...
 
Is Makefile supposed to be capitalized?
 
ah hm
 
5:29 PM
Because it's more towards the top that way
 
brb - have to restart
 
That's giving me interesting results back
Ayyy, shadowing breaks things
Who woulda knew
 
@BryanEdds I sort headers from most-local to least-local. So stdlib headers are always last.
Usually
my.h

my_libs.h

boost_libs.h

system_libs.h

stdlib
Within each section I sort the headers alphabetically.
 
ya - I need to accommodate for that approach - even if I don't use it
 
@BryanEdds Your love for shadowing is causing some problems on GCC
 
5:42 PM
should be able to just namespace qualify those, yes?
 
dunno, it's your system
 
just throw the namespace in front of the types to fix if you feel like it
but only do so where needed
 
Also, there's 69000 MVP warnings
 
i don't know what an MVP error is
a few strategically-placed namespace qualifiers should fix the first issue
 
@BryanEdds Most Vexing Parse
 
5:47 PM
they're warns, not errors, right?
if so, turn them off for now
 
Well, yes.
Well, no.
 
I need to rewrite the macro probably
 
Turning warnings off is a horrible idea
 
will turn it back on once I figure out how to rewrite the macro
turn it off for now, unless you want to rewrite the macro :)
you'd have to rewrite these macros, I think - github.com/bryanedds/ax/blob/master/src/impl/ax/…
 
I still have no idea as to how they work
 
5:52 PM
then I'd just go ahead and disable the warn for now
again, it's temporary till I figure out how to fix it appropriately
 
typename type::size_type assert_container_constraint_fn();
(void)&assert_container_constraint_fn;
for example constrain_as_container expands to this
I have no idea for how's that supposed to work
OOOOOOH I get it
 
all that does is assert that the given type has a size_type member, so that it conforms in part to the std container type interface
 
This is the most round_about way I've seen this done
 
this is not what you would call 'great code', but it outlines the idea
need some type of static assertion
it will all be replaced when we get concepts anyway
sometime in, you know, 202X
now way concepts gonna make 2017, i think
 
6:13 PM
@набиячлэвэлиь - I posted two fixes for the ggc ci build errors you were getting.
I presume it will work as intended.
 
@BryanEdds I'm working on the constraint macros:
 
static_assert(!std::is_same<typename type::size_type, void>::value, #type " needs to be a container.")
 
oh, we have static_assert in c++ 14?
 
Yeah, obv
It's in C++11
 
6:14 PM
nice
 
// Assert a type is a container.
#define constrain_as_container(type) \
    do { \
        struct tag {}; \
        static_assert(!std::is_same<typename type::size_type, tag>::value, #type " needs to be a container."); \
    } while(false)
I ended up with that^, @BryanEdds
 
looks good
what's the tag for again?
 
@BryanEdds A type that's guaranteed to be unique
 
ah ok
interesting stuff
not 100% sure how it works
hmmmm
 
@BryanEdds typename type::size_type can not be tag, so if it exists we're good
 
6:23 PM
ah, ya
right yep
forgot about the ! in there
fork is looking good, sir ::)
 
Let's see if it builds and I'll make a PR
 
thx
 
ah shit, there's more
one sec
 
6:32 PM
not sure if I should fix header lib code...
hmm...
 
Just fix up the shadowing for now
 
done
unless I missed something
green, baby!
 
[borat]VERY NICE[/borat]
 
does travis have a build path for msvc?
 
Obviously not
There's AppVeyor for that
@BryanEdds It's up
 
6:44 PM
interesting what you did in functional.hpp - does that potentially save a copy?
set up travis, triggering first build
maybe you can star my repo so i can get some free hipster points :)
all green on travis-ci.org/bryanedds/ax too!
i'll have to pop out a static lib from the build as well
 
7:03 PM
@BryanEdds y u badges on separate line
My eyes are bleeding, pls merge #3
 
lol
k
hm, thought i merged everything
ur a little wound up - i'll send you some of my clonazapam :)
 
Clonazepam, sold under the brand name Klonopin among others, is a medication used to prevent and treat seizures, panic disorder, and for the movement disorder known as akathisia. It is a tranquilizer of the benzodiazepine class. It is taken by mouth. It begins having an effect within an hour and lasts between six and 12 hours. Common side effects include sleepiness, poor coordination, and agitation. It may increase risk of suicide. Long-term use may result in tolerance, dependence, and withdrawal symptoms if stopped. Dependence occurs in one-third of people who take clonazepam for longer than four...
> used to prevent and treat seizures, panic disorder
 
merged
 
I have none of those
 
it's the best
 
7:08 PM
inb4 serious drug addiction
 
lol
good work everyone - many many fixes and improvements to ax :)
 
8:00 PM
@caps It's not a feeling. It's a fact. In a better language/better world the compiler would induce the room for optimization (it can't always know, I know). This piece sums up the argument: josephmansfield.uk/articles/need-value-pass-by-value.html
For the rest yes, practically, because of the limitations of the language and a (healthy?) preoccupation with mutable types yes the optimization used to be often required.
However, the situation has become MUCH less accute with move semantics (and especially noexcept), so the optimization has gone back to being premature much more often again.
All the while, even if warranted, the optimization was an optimization with a cost in complexity: passing around references has inherent lifetime issues.
With GSL's explicit ownership annotations (or Rust-like semantics) we can meet in the middle. Hopefully
 
Did I hear "Rust"
 
8:18 PM
@набиячлэвэлиь cool; nice to see how Travis is hooked up IRL
@BryanEdds And C++03 with BOOST_STATIC_ASSERT
 
@sehe What do you mean by "IRL"?
 
...
"for real"?
 
8:41 PM
@sehe Puppy made a weaker/poorer form of that argument. Other loungers persuaded me I should stick with Herb's advice (only take value arguments when you will be moving/copying anyway).
Now I feel conflicted again.
 
@caps It's really not that difficult. There are conflicting goals: first is correct expresion of intent (pass by value UNLESS you need a reference. Duh. It's much safer, easier to reason about and the compiler may generate equivalent (or superior!) code).
The conflicting goal is real life performance. In which case const& can be good to facilitate non-movables. The onus is on the programmer to be disciplined about the lifetime of the received reference (IOW: treat it as a value or as a reference depending on intent)
It makes perfect sense to be conflicted. The language itself is conflicted here.
 
Okay, well, I think I'm persuaded...
It just seems like it makes an assumption that the parameters will be moveable. How is passing by value superior when you're passing in something you don't intend to move-from?
copy elision?
@sehe I guess that's what you're getting at here...
That is, presuming you mean "non-movables" to include types that are moveable but, in a particular instantiation, should not be moved-from (i.e. they need to hold on to their internal state).
The other problem is that it puts the onus on the callers to write std::move when they have a perfectly moveable object (i.e. don't care about its internal state after the call) that is owned by the local stack.
 
9:15 PM
@caps Not sharing a reference is superior. Remember, software needs to be correct first. Indeed, the rest is (premature) optimization.
Sharing references opens up the window for potential error.
 
So hard to let go of const& everywhere...
 
Let it gooooooooooooo, let it gooooooooooooooo
 
You don't need to! It's just enough to think of it once in a while.
 
Think of it once in a while?
 
The old habit isn't "bad" per se. Just realize the downside too
And notice the landscape has changed in c++11/4/7
 
9:17 PM
You seem to be proposing a wholesale replacement of const T& with T (or probably in my case const T) except when immutable reference is actually the desired semantic.
 
Again, with library-grade code there is a lot to be said to take generic arguments by const&. Just make sure to document the semantics ("optimized" value semantics or reference semantics)
@caps I don't seem to say anything of the kind. Reread everything I said and you'll see that I don't.
(The fact it seems so to you proves your bias - it simple surprise at work)
 
9:33 PM
You're arguing that the value semantics are a better default.
Are you not?
 
You're not reading.
 
> pass by value UNLESS you need a reference. Duh.
Your argument is: if correctness is your first goal, then prefer to pass by value unless correct code would dictate otherwise.
 
@caps So you keep repeating that half. And you keep expecting me to repeat the other half too.
I'm stating that semantically passing by value is (obviously) safer. And in the presence of optimizing compilers / move semantics it might be equivalent / better performant. That's all. That doesn't mean that pass by const& is not useful (I've repeated this at least 3 or 4 times with useful scenarios)
@caps Basically. And I wonder what the "if correctness is your goal" is about. When is it not?
 
Of course you're not saying that const& is not useful. You're saying it's not a good default.
@sehe Correctness is always my goal. Some people get wound up about perf and it may seem they sometimes worry about it more than correctness.
 
Don't underestimate the confusion that references cause for optimizers. As long as everything gets inlined, it's usually ok. But once aliasing rules are in the picture, optimizations are toast. Passing by value can be surprisingly fast.
@caps And there are situations where you have to cater for the general case and const& can be the best there. Also, you can weigh the likely costs (cf. the inlining factor I just mentioned)
 
9:40 PM
@sehe "aliasing rules"?
 
444
Q: What is the strict aliasing rule?

BenoitWhen asking about common undefined behavior in C, souls more enlightened than I referred to the strict aliasing rule. What are they talking about?

Compilers will have to consider the possibility of similarly-typed references to refer to the same object via different variables. This kills optimization opportunities big time (since additional load/store cycles have to be done just in case)
 
00:00 - 22:0022:00 - 00:00

« first day (33 days earlier)      last day (26 days later) »