Questions tagged [pointer-aliasing]
59 questions
1
vote
1 answer
How to do aliasing with union or possible with enum?
I have gone through this very good article
https://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule
but I didn't understood of aliasing with union, what I know about aliasing is with char/ unsigned char, which is a compiler…

Jarvis__-_-__
- 287
- 1
- 13
1
vote
3 answers
Messing around with Aliasing
I have the following code that works as expected:
a = [1, 2, 3, 4]
b = a
>>> b is a
True
if I change it up a little it still works:
a = [1, 2, 3, 4]
b = a[2] * 2
>>> b is a[2] * 2
True
Now the problem:
a = [1, 2, 3, 4]
b = a * 2
>>> b is a *…

Timmay
- 85
- 4
- 13
1
vote
3 answers
Is the aliasing rule symmetric?
I had a discussion with someone on IRC and this question turned up. We are allowed by the Standard to change an object of type int by a char lvalue.
int a;
char *b = (char*) &a;
*b = 0;
Would we be allowed to do this in the opposite direction, if…

Johannes Schaub - litb
- 496,577
- 130
- 894
- 1,212
1
vote
1 answer
Array Changes Not Showing Up in Main Method
This code is supposed to perform a "perfect shuffle" on a deck of cards. It represents the division of a deck into two decks and then the subsequent interleaving of them. When I pass in an array and then print out the elements in the returned array,…

user3673010
- 11
- 3
1
vote
3 answers
What happen to stack when i declare a reference variable? C++
When i declare a variable, it will be allocated in stack at a certain index of memory right?
But when i declare a reference variable it will point to the same index of the other one, so no new space have to be allocated in stack...
How does the…

Andrea Biagioni
- 174
- 10
1
vote
4 answers
Is there aliasing in a 2-D array in Python?
I know that list aliasing is an issue in Python, but I can't figure out a way around it.
def zeros(A):
new_mat = A
for i in range(len(A)):
for j in range(len(A[i])):
if A[i][j]==0:
for b in…

makansij
- 9,303
- 37
- 105
- 183
1
vote
2 answers
Does CUDA support pointer-aliasing?
The reason why I ask this is because there is some strange bug in my code and I suspect it could be some aliasing problem:
__shared__ float x[32];
__shared__ unsigned int xsum[32];
int idx=threadIdx.x;
unsigned char * xchar=(unsigned char…

user0002128
- 2,785
- 2
- 23
- 40
0
votes
1 answer
My pixijs app 'destroy' pixel when I downsize a big jpeg
I use Pixi.js and I want to down-size a big JPEG but the quality of the picture is affected.
I load the picture like this:
this.App = new PIXI.Application({ background: 'black', resizeTo: window, antialias: true })
this.ironing = await…

ricardo
- 1
- 5
0
votes
0 answers
Managing inventory with multiple SKUs and shared quantities in MySQL Database using Navicat
I have a database where the columns in one of the tables are:
UPC, SKU, AliasOf, Quantity
123456789123, 123456789123a, null, 6
123456789123, 123456789123b, 123456789123a, 0
123456789123, 123456789123c, 123456789123a, 0
123456789123, 123456789123d,…

Pacifico
- 1
- 1
0
votes
1 answer
reuse variable inside yaml for use in c++
I am trying to reuse a variable inside a yaml file which is then going to be read inside a c++ (visual studio). My attempt is not working at the moment. Here is my approach:
Inside yaml file:
testName: &./test.yaml
Later in yaml file I am reusing…
0
votes
0 answers
Calculating a summary of tuples' length not including aliasing in python
Given the following code, I've been asked to calculate how many different tuples (aliasing tuples are to be excluded) are in the returned tuple of the function:
def tuple_maker(k):
result = tuple()
length = len(result)
for i in…

NiceGuy
- 11
- 1
0
votes
1 answer
why customtkinter elements have a strange shape
I'm trying to use customtkinter. i downloaded the examples and when i try theme, all the elements have a strange shape enter image description here which don't look like the screens of the examples on github.
I searched on google but didn't find a…

H Hakim
- 1
- 1
0
votes
2 answers
Preventing memory aliasing when copying mem blocks in C
I think I'm getting rusty, so please bare with me. I'll try to be brief.
Q1. When trying to copy buffers, say buf2 to buf1, does the following check suffice against aliasing?
if (buf2 >= buf1 && buf2 < buf1 + buf1size) {
// aliasing
}
Q2. If…

Harry K.
- 560
- 3
- 7
0
votes
2 answers
C++ template/aliasing - Type/value mismatch at argument 1 in template parameter list
I'm getting my feet wet with aliasing in templated classes, and haven't been able to compile the following code:
template using item_ptr = std::shared_ptr;
class Container
{
std::vector list;
};
I get two compile errors,…

Jarom Allen
- 21
- 3
0
votes
1 answer
Why is my base case being (erroneously) triggered immediately?
I am trying to implement a merge sort algorithm in C. In the recursive array split function, my base case is occurring infinitely, despite the return statement, and the merge function is never called. Here is my code:
#include
const int…

Turboninja99
- 1
- 1