67
339
u/depicc Sep 12 '19
Usually always the ending brace down there
73
u/amberdesu Sep 13 '19
Ending brace don't usually return the "right" error. It just returns a function/var undefined error on some other line.
Could just be C, C++ idk
14
Sep 13 '19
Js as well. Usually reports the last line of the file as the location
2
u/Arheisel Sep 13 '19
For me this usually means that either a semicolon, a parenthesis or a bracket is missing somewhere, not super helpful but I immediately know what to look for.
3
Sep 13 '19
Same. Hopefully I only did one brace related thing sin e my last test so it's easy to isolate, especially with the Vscode rainbow plugin that colour codes all closures. But then other times you go on a roll and write 4 new functions and modify 3 others between tests
2
u/Kered13 Sep 13 '19
That's because in many curly brace languages everything that follows is valid syntax inside curly braces. So no actual error occurs until the file ends and there is an unclosed curly brace. And the compiler can't tell where you intended to close the block, so it can only report the last line of the file.
1
Sep 13 '19
browsers can make an educated guess when you don't close a tag.
Catch up compilers!
1
u/Kered13 Sep 13 '19
Browsers can do that because HTML consists of matching opening and ending tags. Curly bracket languages have different opening "tags", but they all close with the same tag.
The smart thing to do would actually be to read indentation and use that to suggest where you may have intended to close the block.
7
Sep 13 '19
[removed] — view removed comment
28
3
149
u/arc_menace Sep 12 '19
Dont you love it when you call a vector out of bounds and instead of telling you, the debugger just says there is an error on line 1776 of vector.h
52
u/fghjconner Sep 13 '19
And that's why God invented stack traces.
1
Sep 13 '19
Well that makes sense, as I'm pretty sure the folks I was tutoring were disciples of Satan.
20
21
Sep 13 '19
Technically it's right though. The actual memory access is happening inside the vector template class member functions.
And there is no vector.h. It's not a standard header since it doesn't have an associated source or compiled library, it's just a template class. It's just <vector>.
1
1
Sep 13 '19
On some systems, <vector> might include a file named vector.h. It's implementation detail after all. I actually saw this on macosx I think
1
Sep 13 '19
What is a vector template and a memory access and template class ELI5? Just learned C++ and wanna learn
1
Sep 13 '19
A template class is just that. A class that acts as a template that can be applied to any number of types or classes.
For instance std::vector is a template that can be used to create a vector of floats, ints, or any other arbitrary object type.
A memory access is exactly what it sounds like. Accessing a location of memory. This happens any time you create, access, destroy, or use an object.
1
u/arc_menace Sep 13 '19
I am fully aware the error is in fact in <vector> it just seems like an obtuse way of saying I called a vector out of bounds...
4
u/xxkid123 Sep 13 '19
1
80
u/tylercoder Sep 12 '19
C++ Gang Represent
8
6
28
23
u/janisozaur Sep 12 '19
27
u/DreadLord64 Sep 12 '19
Oh, hey, you're one of the Archlinux Core devs. I just wanna say thanks for the work you do. My machine is running great thanks to the work all you guys do.
20
u/homelessmeteor Sep 12 '19 edited Sep 12 '19
Inlining.
11
7
u/cartechguy Sep 13 '19
python: I'll ignore your untied shoes and watch you trip and fall when you're running.
11
10
5
3
3
Sep 12 '19
I honestly wonder why does this happen though I'm 16 year old student and we're learning C++ in our school and I'd like to know what causes this so I know how to and where to find those damn bugs that cause it....
10
u/Bakoro Sep 13 '19 edited Sep 13 '19
One of the things you should know about C/C++ and probably many other languages, is how compiling and linking code works.
The extremely shortened explanation of this specific problem is that when you write those "#" statements, what you're doing is putting in a preprocessor directive. These preprocessor directives happen before compilation actually begins: basically the compiler goes through and does those commands before it looks at other parts of your code.
In C/C++ you have to at least declare a function/struct/class before you use it. It'd be a stupidly long file if you tried to declare and define everything in the same file, so that's one of the reasons you have those "#include" statements. When you write "#include", what the compiler does is include the entire contents of that file into the file you're compiling. Basically the compiler acts as if everything in the included file is copy-pasted before the body of your own code, that's what allows you to use classes and functions like cout and cin and everything else you didn't write in your file. So, when you #include <iostream> or <"whateverOtherFile.h">, just think about it as copy-pasting all the code from that file into your own file.
Now you should see what the problem is. You #include something with 100 lines of code. Then you write 40 lines of your own code using some class or function from the #include file. You make an error using that function, so line 60 of the the code is what's throwing a fit. When you are using a poorly documented library (or several) you have no control over, this can be a serious problem trying to figure out what happened where, but compilers are fairly good at telling you what went wrong if you passed in the wrong variable type or something. The bigger the code base the harder it is to pin down exactly where the issue pops up, which is one area where debuggers really come in handy.6
2
u/TheAuthenticFake Sep 13 '19 edited Sep 13 '19
Something really nasty about this is that the included headers may rely on declarations from above it in the translation unit. For example, you might have two headers and a macro at the top of a file Q.cpp:
#include "A.h" #define B 5 class C; #include "D.h"Header D.h may have a dependency on declarations in A.h, the definition of the macro B, and the forward declaration of C. Without these it will fail to compile. Whenever you include D.h, you have to include all of those dependencies. When you're trying to include and link D.h from a library, this may simply not be possible.
This has to be my most hated "feature" of C/C++ because it breaks modularity so badly. In a large system, it can be really challenging to untangle components to make them more reusable because of this issue.
3
3
5
u/reaperindoctrination Sep 12 '19
What is the source for this image? I want to learn more.
0
Sep 12 '19
[deleted]
4
u/odel555q Sep 12 '19
Is there some reason that it's so devastating to die in Minecraft?
13
u/MaxwelFISH Sep 12 '19
https://www.youtube.com/watch?v=_u7gt7F8Ue8
Died to a trap and was absolutely devastated
7
u/odel555q Sep 12 '19
But my question is why is it so devastating? Can't he just respawn or start over or something? Do you only get to have a single life in Minecraft, and then you can never play it again?
19
u/BOESNIK Sep 12 '19
It was during a tournament for $10k.
Where 48 players all try to kill each other, so you want to stay alive for as long as possible.
10
u/MaxwelFISH Sep 12 '19
Was playing Survival Games or something on Minecraft Mondays. Once you die you can't respawn in that round and if you win Minecraft Mondays you get a lot of money or something
6
2
2
2
2
2
2
2
2
u/tomysshadow Sep 13 '19
I remember I used to write JS and sometimes I'd get an error on line 1 where the <html> tag is... what!?
2
2
2
2
2
2
2
Sep 13 '19
It was confusing. I was using Vue for my project and it threw like 5 errors on line: 1000+ im like what the fuck my code is only 100 lines.
1
1
1
u/theInfiniteHammer Sep 13 '19
Try recompiling everything. It's probably that someone didn't properly wrap their data structures with accessor functions.
1
Sep 13 '19
I still remember that discovery in Spyder. I had like 200 lines of code and has errors on like line 2000. Came to realize I has to scroll through all those errors to find the line that caused it.
1
1
u/THICC_DICC_PRICC Sep 13 '19
Or when you’re integrating an external API and their system doesn’t return error codes or description, just a simple “error” with zero clues
1
1
1
1
u/aenimafacilis Sep 13 '19
Probably just pointing to an address. Debug would find the address most likely
1
1
1
u/YappyDoor Sep 13 '19 edited Sep 19 '19
Why C++? Python (for example) can do that too. He also have external libraries. And many others langs too
3
u/GYN-k4H-Q3z-75B Sep 13 '19
Because C++ produces infinitely more fucked up error messages because templates are magic.
1
u/redshadus Sep 13 '19
When I was installing NodeJS on my VPS, I tried to install it as the documentation stated, but I would always get a runtime error because something was broken in the NodeJS code
1
1
u/ICAA Sep 13 '19
I had a classmate who forgot a semicolon after declaring his class in C++. He also included that header first so I ended up looking for the error in the middle of a Qt.
I never thought the missing semicolon jokes could had any relevance on someone using an IDE.
1
u/snarfy Sep 13 '19
C++ - instead of "error: missing semicolon", you get 400 lines of template compiler vomit.
1
0
u/RisibleComestible Sep 13 '19
You are a fucking error on line 60. There never was a line 60 you n00b
2
-9
-30
u/maks25 Sep 12 '19
This sub has gone to shit.
28
u/smubear_ Sep 12 '19
nobody's forcing you to stay
6
3
u/Bomaruto Sep 12 '19
We want it to get better, but that's quite unlikely. I try to report the posts I see violates the rules, but there will always be more people breaking them.
0
2
0
Sep 12 '19
[deleted]
580
u/DmitriRussian Sep 12 '19
This is why source maps were invented!
55
u/Peechez Sep 12 '19
Jokes on you I write minified and obfuscated code as my source
52
u/stamminator Sep 12 '19
My code is so bad that everybody thinks it's obfuscated and I just haven't corrected them
36
Sep 12 '19
Had an old coworker who used to patch the minified js from a library we used by hand. He just grabbed paper to make notes about what symbol was what variable and stepped through it. It was horrifying and amazing at the same time.
44
u/Dregre Sep 12 '19
You haven't seen true insanity yet. A former employee at the a former company I worked for more or less read byte-code for micro controllers. The guy was a wizard that could rip the compiled code no one knew and fix a bug without looking at the original source.
11
6
Sep 12 '19
Reminds me of the story of Mel.
http://www.catb.org/~esr/jargon/html/story-of-mel.html
These people are in a league of their own. I’m over here feeling good cause I know c# and js pretty good and people are editing compiled programs.
5
1
Sep 23 '19
Well, it's actually no black magic once you use a disassembler and perhaps debugger and start taking notes. When you instead look just at the byte code and are somehow able to parse that accurately inside your head, well that sounds about as likely as photographic memory or something.
2
5
3
Sep 13 '19
The source maps for my sass are fucked somehow so chrome tells me the styles for an element are in an unrelated partial
2
1
u/Dokii Sep 24 '19
For some reason my errors still give me incorrect lines. It's closer, but for some reason don't match the source code.
I'm using this boilerplate for using Vue with electron. I'm feeling like I'm going to have to drop using Vue/webpack if I can't get useful errors :(
0
Sep 12 '19
[deleted]
218
u/DmitriRussian Sep 12 '19
Perhaps this will help you: https://survivejs.com/webpack/building/source-maps/
4
u/mitwilsch Sep 13 '19
Thanks, saving for later. One of these things I always find annoying but doesn't come up enough to bother fixing 😁
0
Sep 12 '19
[deleted]
76
u/CommunismDoesntWork Sep 12 '19
I love your username
0
Sep 12 '19
[deleted]
142
u/commie_heathen Sep 12 '19
I don't like either of yours!
2
0
Sep 12 '19
[deleted]
45
u/commie_heathen Sep 12 '19 edited Sep 12 '19
Filthy bourgeois!!
Edit: /s, c'mon people
→ More replies (0)0
Sep 13 '19
[deleted]
5
u/CommunismDoesntWork Sep 13 '19
If you think the world is going to shit, you're addicted to bad news.
Here take this quiz:
https://humanprogress.org/quiz?p=2064
And here's some data you can use as a cheat sheet:
0
Sep 13 '19
[deleted]
1
Sep 21 '19
As somebody who got into programming because of userscipts...I really enjoy Javascript but it also sucks.
7
u/Shulamite Sep 12 '19
Not until vue3 when template sourcemap is implemented.For now you had to deal with it or use render function instead
0
2
u/TerrorBite Sep 13 '19
You can have Webpack output a source map, and the browser inspector will actually parse that source map and reconstruct the original file tree and source code in the inspector.
3
Sep 13 '19
Not super helpful, but to let you know the tech works... I work with Angular a lot, and that transpiles typescript code to javascript code, which gets uglified and concatted into one massive unrecognizable pile of ugly. Yet chrome always tells me "Error on line 23 of SomeComonent.ts". It's lovely.
1
u/n60storm4 Sep 13 '19
Yep it's that simple. I even have sourcemaps to to my typescript and it just works.
0
u/ProgramTheWorld Sep 13 '19
Source maps work by mapping the tokens in the output JS file back to the original files, so yes it would.
22
u/semitic-simian Sep 12 '19
Source maps my friend
44
0
u/dangerCrushHazard Sep 12 '19
Idk I can’t get them to work. Even with source maps, it still shows error on line X in the complied code; but in the code toolbar I can see the source code, but not the error.
(This was on fX)
9
Sep 12 '19
I just learned about sourcemaps last week. They are a lifesaver. When you are developing go to the webpack config file and set mode to "development"
14
u/patrickfatrick Sep 13 '19
I know every else has already said this but I just want to make it abundantly clear that 👏source 👏 maps 👏 are 👏 your 👏 friend. Please use them.
0
Sep 13 '19
[deleted]
20
Sep 13 '19
They're talking about javascript, so probably astrological star charts.
2
u/guitpick Sep 16 '19
Here's what you're looking for: https://www.lonelyplanet.com/maps/asia/indonesia/java/
1
u/JustSpeedy Sep 13 '19
it shows your source code in the chrome debugger and the right code line in error messages even tho your code has been minified.
3
2
u/SuperFLEB Sep 13 '19
This used to bite me back in the days before all that web-packin' and source mappin' back in the dark days of IE.
1
0
0
Sep 13 '19
[deleted]
1
u/exhuma Sep 13 '19
As someone only half-arsedly dabbling in JS from time to time, what would you recommend?
0
241
u/neros_greb Sep 12 '19
Compilers normally say the filename as well as the line