[ / / / / / / / / / / / / / ] [ dir / adv / animu / asatru / cafechan / mai / sw / vg / zurdopol ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Name
Email
Subject
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 0b1df90eb319554⋯.jpg (9.03 KB, 250x241, 250:241, 51fYzbYoXFL._UX250_.jpg) (h) (u)

[–]

 No.900019>>900541 >>900613 >>900810 >>903766 >>904681 >>905644 [Watch Thread][Show All Posts]

Compile with

>-Wall -Wextra -pedantic -O2 -Weffc++ -Wconversion


struct Object {
Object()
: member{4}
{}

void mutate() {
++member;
}

int member;
};

struct Foo {
Foo(Object& obj)
: obj{obj}
{
use_object();
}

void use_object() {
obj.mutate();
}

Object& obj;
};

struct Bar {
Bar()
: f{obj}
, obj{}
{}

Foo f;
Object obj;
};

int main() {
Bar b{};
}

 No.900020>>903766 >>905279

This can't happen in rust


 No.900022>>903766

Use Rust next time


 No.900541>>900594

>>900019 (OP)

Honest question as my C++20782381238 is rusty: what exactly is the problem here and what should the compiler warning be?

Is it the order of initialization that bugs you, or what?

General C++ rant:

I'm frustrated with the tons of new features constantly pouring in since C++11. [s]Wow, we have std::filesystem stuff now! Cool, 20 fucking years too late but still. But if they focused on the practical stuff like this first and foremost, we wouldn't have kick-ass stuff like std::string_view and folding expressions, which we totally needed. How's the concepts coming up?[/s]


 No.900549>>900567 >>904674 >>905907

Want something else that compilers don't warn about? Casting a const char* to a char*.


 No.900567>>900594

>>900549

>point gun at self

>shoot

>ban all guns XDD

fucking KEK


 No.900568>>900594

>why doesnt a compiler warn me about every single retarded thing I can think of. come on c sucks XD


 No.900569>>900594

>cut self in the finger with a knife

>wtf why don't knives have safeties?

>i mean COME ON it's 2018!!!!


 No.900594>>900603

>>900567

>>900541

>>900568

>>900569

the point here is not doing this shit on purpose but the fact that if you have a large projectr the problem in the OP can easily happen

a compiler warning at this point would be nice to reduce years of looking through code to find the problem


 No.900603>>900607

>>900594

>what is static code analysis???

wow so hard. go suck some bbc you faggot

>insert dick into unlubed fleshlight

>rip dick

>wtf why didn't anyone warn me


 No.900607>>900611

>>900603

which tool warns about the issue at hand?

feel free to back up your claims anytime


 No.900611>>900614

>>900607

Rust XDDDD

>go into black neighborhood

>yell 'i hate niggers'

>get killed

>wtf


 No.900613

>>900019 (OP)

>play stupid games

>win stupid prizes

What is it about cocks that entices you so much, OP?


 No.900614>>900615

>>900611

wait, do you even know what the problem is or are you just larping?


 No.900615>>900618 >>904950

>>900614

The problem is that you wrote incorrect code and then whine that your shit is fucked.

Write correct code next time.


 No.900618>>900621

>>900615

so you don't know the problem...


 No.900621>>900623 >>900625

>>900618

The problem is that you are basically retarded and expect the compiler to do the work for you.

Write correct code next time or use Javascript


 No.900623>>900624

>>900621

>if i keep acting like a nigger then i win the argument


 No.900624>>900626

>>900623

I'm actually just pretending to be retarded.

I mean what do you expect trying to tell /tech/ that C/C++ isn't perfect?


 No.900625

>>900621

Come on now, the OP is clearly a faggot that writes bad code because he can't see the computer screen with all that /cuteboy/ cum in his eyes, but you're being evasive.


 No.900626>>900627 >>904680

>>900624

C is perfect, C++ is an abomination.


 No.900627>>904680

>>900626

Found the LARPer


 No.900770>>900773

I'm on my phone so I can't compile, but I see the issue, it's that you're using the obj before it is created. Well, that will crash, you look into the debugger and discover that the argument passed is 0. Not hard to figure out at all. Shit like this would be caught by clang format probably anyway. OPdoesn't have any arguments. If it's just you and fairly small program, this is unrxcusable, if it's big corpo project, there's constant code reviews, unit tests, starical analysis, people are all about "clean code" by that faggot uncle bob. This would never pass unless the code is outsourced to pajeets or something.


 No.900772

btw OP, did you report it to the gcc team or to some other compiler people ? I doubt it.


 No.900773

>>900770

>faggot uncle bob

kek


 No.900810>>901069

>>900019 (OP)

It's because you passed -pedantic when you clearly meant -autistic.


 No.901069

>>900810

This tip saved me HOURS of debugging!

Thanks!


 No.901168>>901191

>constructors

absolutely harmful


 No.901191


 No.903766>>904112 >>904121 >>905615

File (hide): 6d2b4ea345f3d4b⋯.png (785.06 KB, 2955x2785, 591:557, rust shill hd.png) (h) (u)

>>900019 (OP)

>>900020

>>900022

>samefagging this hard

>being the meme

>>>/soyboys/


 No.904112>>904153

>>903766

get fucked, cuck.


 No.904121>>904139 >>905615

>>903766

what font is that? looks neat


 No.904139>>904141 >>905615

File (hide): b69d27bc16e1b60⋯.png (64.7 KB, 1185x736, 1185:736, 70e88dfe-f680-430b-b077-fc….png) (h) (u)


 No.904141>>904219 >>905615

>>904139

No, the punctuation in that image uses rectangular shapes. Ubuntu Mono uses round shapes.


 No.904153

>>904112

get cucked, fuck.


 No.904219>>905615

>>904141

It's not Ubuntu Mono. Fontsquirrel doesn't seem to recognize it either.


 No.904674

>>900549

what shit compiler do you use that doesn't give a warning for this?


 No.904680

>>900626

>>900627

What's the problem with C?


 No.904681

>>900019 (OP)

Did he step off the Mayflower yesterday?


 No.904696>>904932

Trying to learn C++ here, is the problem that in struct Foo obj is called with obj{obj} but inside struct Object there is no correlating match? What's the problem here?


 No.904713

No Rust? Into the trash.


 No.904722>>904919

Thread is shit if OP doesn't explain why a compiler should generate a warning for this code.


 No.904919

File (hide): 07ff8e7f775e2dd⋯.png (437.94 KB, 540x720, 3:4, 1481714994279.png) (h) (u)

>>904722

t. brainlet


 No.904932>>905244

>>904696

obj is passed into f before obj is initialized. f uses obj in its ctor which results in UB

to fix it you swap the order of initialization in bar


 No.904950>>905006

>>900615

>I've never written anything more complicated than FizzBuzz

Nice of you to let us know.


 No.905006

File (hide): 7c99cad7f46835c⋯.png (34.22 KB, 621x942, 207:314, hurr_fizzbuzz.png) (h) (u)

>>904950

>fizzbuzz can't be complicated

Kindly explain how exactly pic related werks as well as all of its quirks and oddities.


 No.905208>>905322

Because the compiler can't make sense of C++ either.

As DLW says, "C++ is the C of object oriented programming languages."

Subject: C++ Is Good For Fertilizer

This message is in reply to a "discussion" spurred by the
"observation" that (I quote roughly and from memory)
"Computers are used by 50% of the people in the world, and C
is used by 50% of all programs, therefore improving C [ie
incrementing it and discarding the result] will potentially
make the world a 25% better place to live." I am not making
this up.

The original subject line for the discussion was "C++ is
good for the world."


 No.905244

>>904932

Thanks anon.


 No.905279

>>900020

Oops, forgot trip.


 No.905322

File (hide): 967d77ec3591718⋯.gif (48.81 KB, 500x129, 500:129, iceburn.gif) (h) (u)

>>905208

God DAMN


 No.905325>>905330 >>905616

It doesn't warn you, because it assumes you're smart enough to know that modifying data before it's even initialized is fucking retarded.

int main()
{
int x;
++x;
x = 4;
return x; //hurr why isn't it returning 5??? muh safety
}


 No.905330>>905619

>>905325

languages that force variables to be initialized before they're used won't let this happen

does rust enforce this?


 No.905615

>>904121

>>903766

>>904139

>>904141

>>904219

if anyone else cares, it's mononoki


 No.905616

>>905325

>I enjoy security errors that could trivially be prevented by the compiler


 No.905619>>905642

>>905330

>does rust enforce this?

yes???????????????????? even pajeet languages enforce this.


 No.905642>>905895

>>905619

like javascript? :^)


 No.905644>>905648

File (hide): 6eb4c49e046e435⋯.png (106.39 KB, 423x578, 423:578, 15137924563180.png) (h) (u)

>>900019 (OP)

use haskell, oop is trash


 No.905648>>905670 >>905889

>>905644

his examples hardly use any OOP

or did you really mean functional/imperative programming?


 No.905670

>>905648

>engaging a larper


 No.905889

>>905648

use of methods and shit


 No.905895

>>905642

No. Like Java, C#, Dart, Swift, Objective-C. I wouldn't classify JavaScript as a pajeet language. JS is just shit.


 No.905907

>>900549

>compilers don't warn about

<warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

What shit compiler are you using?


 No.906319>>906324 >>906940

Compile with rustc. Safe code can't access freed memory.

fn main() {
let v = vec!(0, 1, 2, 3);

match () {
() if free(v) => { unreachable!(); }
_ => { println!("{:?}", v); }
}
}

fn free<T>(_: T) -> bool {
false
}
This outputs
[0, 0, 0, 0]
Ooooooopsie


 No.906324>>906940


 No.906940

File (hide): cf9c6abcf1aeb22⋯.jpg (12.73 KB, 260x222, 130:111, 13784358234.jpg) (h) (u)




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
64 replies | 9 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / adv / animu / asatru / cafechan / mai / sw / vg / zurdopol ][ watchlist ]