c++
int abc() {
int i = 5;
i += 10;
if (i == 15) {
return 0;
} else {
return 1;
}
}
i
will never have a memory locationi
is never in any kind of memoryi
is never in any kind of memory i
will never be in main memory and it will never be in a registerxor eax, eax
return 0
i
xor eax, eax
31 ed xor ebp,ebp
int
with the location of the int instead of where its value is stored?int
with the location of the int instead of where its value is stored? a = &b
and not a = b
int
with the location where 69 is storedint
s can exist without being able to get their address takenregister int x
in Cregister int x
in C An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address). rvalues are defined by exclusion.
An lvalue is an expression with object type
. If you want a more layman form of it something that can be assigned to
also works fine since that was actually how it was initially defined. If something can appear on the left side of an assignment it's an l-valueL-value: “l-value” refers to memory location which identifies an object. l-value may appear as either left hand or right hand side of an assignment operator(=).
int array[10];
, array
is an lvalue as it's an expression with object type, however it's not a modifiable l-value, so it can't appear on the LHS of an assignment*(int *)123
is an l-value*((int *)x + 5)
is still an l-value&a
is an address, but it's an r-value. if you define l-value as address, then you get misled&a = &b
&a
is always an r-value, in every context&a
you mean address of a
which is just a normal valueThe unary & (address-of) operator requires an l-value as its operand. That is, &n is a valid expression only if n is an l-value. Thus, an expression such as &12 is an error. Again, 12 does not refer to an object, so it’s not addressable. For instance,
a
is an lvalue, &a
is an rvalue. Yeptest.cpp:11:11: error: cannot bind non-const lvalue reference of type ‘int*&’ to an rvalue of type ‘int*’
11 | PrintInt(&a);
&a = p; // error: &a is an r-value
int a = 0;
. a
is an object. a
is also an l-value. a
has a value it's 0
a
is an l-valuea
is an l-value, we apply the &
operator, we get &a
an r-value, we apply the *
operator, we get *a
an l-valuesizeof
operator, sizeof a
and we get a r-value&a
which is an r-value but is the address of aint anya1 = 69; int *anya2 = &anya1; int **anya3 = &anya2
This is sort of the mental picture I'd have about the memeint anya1 = 69; int *anya2 = &anya1; int **anya3 = &anya2
This is sort of the mental picture I'd have about the meme cf7570c
Version 16.2 - def-
f12f971
Update Korean translations by CHaBek - cwh7435
ec684f2
Added new translations + fixed current one - crqch
42f4d93
Fix Leak IP not visible - crqch
4bef015
Remove accidentally added double type - Robyt3
9933b3c
Update comment - Robyt3
342b5b5
Fix editor value scrollers not working and panning being slow - Robyt3
48c4cfd
Improve some german translations - Jupeyy
be4ae02
Update Brazilian Portuguese translation (supersedes #5304) - def-std::forward
std::forward
does is automatic in rust?std::forward
does is automatic in rust? c++
template <typename T1, typename T2>
void wrapper(T1 e1, T2 e2) {
func(e1, e2);
}
&
always wins. So & &
is &
, and so are && &
and & &&
. The only case where &&
emerges from collapsing is && &&
. You can think of it as a logical-OR, with &
being 1 and &&
being 0.(void)pMsg;
can be omitted or does it do anything? (edited)CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
I get a lot of the following warnings:
/usr/bin/ld.gold: warning: Cannot export local symbol '__asan_extra_spill_area'
CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
I get a lot of the following warnings:
/usr/bin/ld.gold: warning: Cannot export local symbol '__asan_extra_spill_area'
CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)
I get a lot of the following warnings:
/usr/bin/ld.gold: warning: Cannot export local symbol '__asan_extra_spill_area'
=================================================================
==14741==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
#0 0x4e11df (/home/arda/ddnet/build/DDNet+0x4e11df)
#1 0x56b9d5 (/home/arda/ddnet/build/DDNet+0x56b9d5)
#2 0x54ab3a (/home/arda/ddnet/build/DDNet+0x54ab3a)
#3 0x9b63fb (/home/arda/ddnet/build/DDNet+0x9b63fb)
#4 0x9b2308 (/home/arda/ddnet/build/DDNet+0x9b2308)
#5 0x1d9cb53 (/home/arda/ddnet/build/DDNet+0x1d9cb53)
#6 0x7fa3b5532ead (/usr/lib/libpthread.so.0+0x8ead)
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7fa3aaad1251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7fa3b7af7a11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 222664 byte(s) leaked in 7 allocation(s).
Hmm, i get this message when i close the game=================================================================
==14741==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
#0 0x4e11df (/home/arda/ddnet/build/DDNet+0x4e11df)
#1 0x56b9d5 (/home/arda/ddnet/build/DDNet+0x56b9d5)
#2 0x54ab3a (/home/arda/ddnet/build/DDNet+0x54ab3a)
#3 0x9b63fb (/home/arda/ddnet/build/DDNet+0x9b63fb)
#4 0x9b2308 (/home/arda/ddnet/build/DDNet+0x9b2308)
#5 0x1d9cb53 (/home/arda/ddnet/build/DDNet+0x1d9cb53)
#6 0x7fa3b5532ead (/usr/lib/libpthread.so.0+0x8ead)
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7fa3aaad1251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7fa3b7af7a11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 222664 byte(s) leaked in 7 allocation(s).
Hmm, i get this message when i close the game CCharacter *pLocalChar = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID);
return null when use spec. but i need to get a variable for the local player, is it possible to do this during spec? (edited)=================================================================
==4866==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
#0 0x4e11df in malloc (/home/arda/ddnet/build/DDNet+0x4e11df)
#1 0x56b9d5 in CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(CCommandBuffer::SCommand_CreateBufferObject const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1901:25
#2 0x54ab3a in CCommandProcessorFragment_OpenGL::RunCommand(CCommandBuffer::SCommand const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1107:49
#3 0x9b63fb in CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:248:20
#4 0x9b2308 in CGraphicsBackend_Threaded::ThreadFunc(void*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:77:25
#5 0x1d9cb53 in thread_run(void*) /home/arda/ddnet/src/base/system.cpp:721:2
#6 0x7ffaf5e76ead in start_thread /builddir/glibc-2.32/nptl/pthread_create.c:463:8
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 in calloc (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7ffaeb3f8251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 in realloc (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7ffaf843ba11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 222664 byte(s) leaked in 7 allocation(s).
CCharacterCore *pCharacter = &m_pClient->m_aClients[ClientID].m_Predicted
if you really nead a CCharacterCore and want the predicted data if available. Thats what I have done in the new hud. But if you do not need predicted data you should use the snap data in m_pClient->m_Snap
, that contains most of data the client got from the server. (edited)2abbfed
Upgrade Discord SDK to version 3.2.1 (includes macOS arm64) - def-8b64081
Upgrade Discord SDK to version 3.2.1 (includes macOS arm64) - def-git log
tell as last commit?=================================================================
==4866==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
#0 0x4e11df in malloc (/home/arda/ddnet/build/DDNet+0x4e11df)
#1 0x56b9d5 in CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(CCommandBuffer::SCommand_CreateBufferObject const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1901:25
#2 0x54ab3a in CCommandProcessorFragment_OpenGL::RunCommand(CCommandBuffer::SCommand const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1107:49
#3 0x9b63fb in CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:248:20
#4 0x9b2308 in CGraphicsBackend_Threaded::ThreadFunc(void*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:77:25
#5 0x1d9cb53 in thread_run(void*) /home/arda/ddnet/src/base/system.cpp:721:2
#6 0x7ffaf5e76ead in start_thread /builddir/glibc-2.32/nptl/pthread_create.c:463:8
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 in calloc (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7ffaeb3f8251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 in realloc (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7ffaf843ba11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 222664 byte(s) leaked in 7 allocation(s).
=================================================================
==4866==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 216320 byte(s) in 3 object(s) allocated from:
#0 0x4e11df in malloc (/home/arda/ddnet/build/DDNet+0x4e11df)
#1 0x56b9d5 in CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(CCommandBuffer::SCommand_CreateBufferObject const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1901:25
#2 0x54ab3a in CCommandProcessorFragment_OpenGL::RunCommand(CCommandBuffer::SCommand const*) /home/arda/ddnet/src/engine/client/backend/opengl/backend_opengl.cpp:1107:49
#3 0x9b63fb in CCommandProcessor_SDL_GL::RunBuffer(CCommandBuffer*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:248:20
#4 0x9b2308 in CGraphicsBackend_Threaded::ThreadFunc(void*) /home/arda/ddnet/src/engine/client/backend_sdl.cpp:77:25
#5 0x1d9cb53 in thread_run(void*) /home/arda/ddnet/src/base/system.cpp:721:2
#6 0x7ffaf5e76ead in start_thread /builddir/glibc-2.32/nptl/pthread_create.c:463:8
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 in calloc (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7ffaeb3f8251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 in realloc (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7ffaf843ba11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 222664 byte(s) leaked in 7 allocation(s).
=================================================================
==27217==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 6240 byte(s) in 3 object(s) allocated from:
#0 0x4e1387 in calloc (/home/arda/ddnet/build/DDNet+0x4e1387)
#1 0x7eff73a46251 (/usr/lib64/dri/radeonsi_dri.so+0xbb5251)
Direct leak of 104 byte(s) in 1 object(s) allocated from:
#0 0x4e1548 in realloc (/home/arda/ddnet/build/DDNet+0x4e1548)
#1 0x7eff80a97a11 (/usr/lib/libSDL2-2.0.so.0+0x9da11)
SUMMARY: AddressSanitizer: 6344 byte(s) leaked in 4 allocation(s).
Conditional jump or move depends on uninitialised value(s)
==31109== at 0xEA773E8: ???
==31109== by 0xE286FBE: ???
==31109== by 0xDEFD5E1: ???
==31109== by 0xDEFD92A: ???
==31109== by 0xE289067: ???
==31109== by 0xE2891A4: ???
==31109== by 0xE28C08D: ???
==31109== by 0xE377511: ???
==31109== by 0xE377B87: ???
==31109== by 0xE3381F4: ???
==31109== by 0xE50F6E4: ???
==31109== by 0x165867: CCommandProcessorFragment_OpenGLES3::Cmd_Clear(CCommandBuffer::SCommand_Clear const*) (backend_opengl3.cpp:816)
==31109== Uninitialised value was created by a heap allocation
But that's probably deep inside the driverConditional jump or move depends on uninitialised value(s)
==31109== at 0xEA773E8: ???
==31109== by 0xE286FBE: ???
==31109== by 0xDEFD5E1: ???
==31109== by 0xDEFEF1F: ???
==31109== by 0xDEF3C1D: ???
==31109== by 0xDEE6FFC: ???
==31109== by 0x4FF6A8D: ??? (in /usr/lib/libSDL2-2.0.so.0.22.0)
==31109== by 0x212CF4: CCommandProcessorFragment_SDL::Cmd_Swap(CCommandBuffer::SCommand_Swap const*) (backend_sdl.cpp:188)
same with this[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 129601200 for frame 2 (staging buffer)
[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 129601200 for frame 2 (buffer)
[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 14862640 for frame 2 (staging buffer)
[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 14862640 for frame 2 (buffer)
[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 9778080 for frame 2 (staging buffer)
[2022-06-22 23:20:19][vulkan]: allocated chunk of memory with size: 9778080 for frame 2 (buffer)
[2022-06-22 23:20:19][vulkan]: recreating swap chain requested by acquire next image (prepare frame).
[2022-06-22 23:20:20][vulkan]: recreating swap chain.
[2022-06-22 23:20:20][vulkan]: warning: requested presentation mode was not available. falling back to mailbox / fifo relaxed.
[2022-06-22 23:20:20][vulkan]: minimal swap image count 4
[2022-06-22 23:20:20][vulkan_debug]: Validation Warning: [ UNASSIGNED-BestPractices-Error-Result ] Object 0: handle = 0x55bc2e50ff80, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x5f379b89 | vkGetPhysicalDeviceSurfaceFormatsKHR(): Returned error VK_ERROR_SURFACE_LOST_KHR.
[2022-06-22 23:20:20][vulkan]: vulkan error: The device surface format fetching failed.
[2022-06-22 23:20:20][assert]: /home/arda/ddnet/src/engine/client/backend/vulkan/backend_vulkan.cpp(1129): The device surface format fetching failed.
[1] 757 illegal hardware instruction ./DDNet "dbg_gfx 4"
./DDNet "debug 1"
might helpdebug 1
gave me a few [uuid]
tagged logs with api calls or somethingscripts/fix_style.py
.
There are two well known Python formatter: autopep8 and black.
I would recommend black
because I have good experiences with it, and I think black has the better default rules but both are good formatter, and we probably want to customize the formatting rules anyway.