|
December 10th, 2019
08:24 pm - Пора на свалку, на свалку пора Знаете, что забавно в этом примере? Нет, не то, что там элементарная ошибка. А то, что компилятор из этого вполне себе создаст исполняемый файл. Варнинг, конечно, будет, и для этого примера отлично виден. Только вот когда проект большой, поймать новое сообщение в летящей простыне вывода практически невозможно.
#include <iostream>
#include <algorithm>
#include <vector>
std::vector<int> make(size_t size)
{
std::vector<int> res;
for (size_t i; i<size; i++)
res.push_back(size-i);
std::sort(res.begin(), res.end());
}
int main(int argc, char *argv[])
{
std::vector<int> data = make(5);
for (int i:data)
std::cout<<i<<" ";
std::cout<<"\n";
return 0;
}
Угу, это по результатам сегодняшних приключений, когда час бился головой об стенку, не понимая, с какого перепуга обращение к std::string даёт ошибку генерала Фолта.
CPP PEDIBUS DESTRUE!
|
Comments:
![[User Picture]](http://lj.rossia.org/userpic/203482/65766) | From: | sadkov |
Date: | December 10th, 2019 - 04:49 pm |
---|
| | | (Link) |
|
>using C++ in 21st century.
Russians must suffer.
no-no-no..c++ very nice lang
![[User Picture]](http://lj.rossia.org/userpic/203482/65766) | From: | sadkov |
Date: | December 10th, 2019 - 05:41 pm |
---|
| | | (Link) |
|
suffer.
ok. I will suffer. What namelly and pointelly lang is not "suffer" and so effective (i mean speed) and low numbers of levels of abstractions from hardware?
question: what result return make function? nullptr?
![[User Picture]](http://lj.rossia.org/userpic/203482/65766) | From: | sadkov |
Date: | December 10th, 2019 - 05:45 pm |
---|
| | | (Link) |
|
The result is undefined. Because C++ allows undefined results.
if you will engage suicide, you need to have this capability, always
The function will return whatever garbage a complier would decide to put in. The Undefined Behaviour in all its ugly glory.
no. it's just "poorly programmad "indussian" " code hehehe
You're wrong: 6.6.3(2): Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function. (Emphasis is mine).
yes-yes-yes. OK!
I think programmers need new c++ -- new "L4 runic language" -- W0RN COMPILER. (but it will emit code so effective like C/C++)
or not include < string > ?
I do not use any strings here, so no need to incude this header.
std::cout << i << " "; std::cout<<"\n";
sorry, if i wrong, i'm not in "programmers mode" right now. (in literature writer mode)
Those are 'string literals' and they have 'const char *' type';
(you use vectro of char, ok. but i do not sure, that it's supports by stream. or some kind of manipulators need to be used)
No need for any manipulations. ostream MUST implement this operator: template basic_ostream [ Error: Irreparable invalid markup ('<char,traits>') in entry. Owner must fix manually. Raw contents below.] No need for any manipulations. ostream MUST implement this operator: template<class traits> basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s); (As per 27.6.2.5.4)
From: | (Anonymous) |
Date: | December 10th, 2019 - 07:13 pm |
---|
| | | (Link) |
|
все программисты — гомосексуалисты; это вытекает из самой сущности программирования.
From: | (Anonymous) |
Date: | December 10th, 2019 - 08:32 pm |
---|
| | | (Link) |
|
Кабинку обмерил уже, говномер? |
|