Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
2 answers
148 views

Can I use the pointer returned by std::vector<std::array<double>>::data()::data() as a pointer returned by an equivalent std::vector<double>::data()? Do I expose myself to potential ...
fghoussen's user avatar
  • 599
5 votes
2 answers
251 views

This is a follow up to Restricted access for allocated arrays belonging to separate object after discovering that returning by value across compilation units doesn't help to hint the compiler about ...
alfC's user avatar
  • 16.8k
0 votes
1 answer
146 views

I created a function that copies strings quickly by copying 8 bytes at a time, similar to the built-in memcpy. In the following function, the char pointer type is cast to an unsigned long long pointer ...
akyoshid's user avatar
1 vote
0 answers
25 views

I know that when you pass an object in as an argument to a method, the formal parameter object in that method becomes an alias of the argument/actual parameter. Unless that's actaully wrong, I don't ...
Angela's user avatar
  • 11
1 vote
1 answer
117 views

Suppose a function int foo(int x) is made available in library libfoo, which I don't control. I do control a codebase which calls foo() many times, in many files. Now, I would like to insert some ...
einpoklum's user avatar
  • 137k
4 votes
3 answers
183 views

Is it a safe code, or can the compiler optimize access through p, such that *p will result in 42? #include <stdio.h> int i = 42; int *d = &i; void test(int const *p) { *d = 43; ...
Hren Sgory's user avatar
0 votes
0 answers
59 views

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,...
Pacifico's user avatar
0 votes
0 answers
40 views

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()...
NiceGuy's user avatar
  • 11
4 votes
0 answers
262 views

Consider the following code: unsafe { let mut s = "".to_string(); let r = &mut s; let ptr = r as *mut String; r.push('a'); (*ptr).push('b'); r.push('c'); ...
rubo's user avatar
  • 437
8 votes
1 answer
2k views

I was working on highly "vectorizable" code and noted that regarding the C++ __restrict keyword/extension ~, Clang's behavior is different and impractical compared to GCC even in a simple ...
Etienne M's user avatar
  • 715
0 votes
2 answers
234 views

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 &&...
Harry K.'s user avatar
  • 650
3 votes
2 answers
396 views

I understand that given this code a = [1,2,3] b = [4,5,6] c = a and then by doing this a[0] = 0 I wil change first positions of both a and c. Could somebody explain why this doesn't apply when I do ...
kubajed's user avatar
  • 31
0 votes
1 answer
52 views

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....
Turboninja99's user avatar
-2 votes
1 answer
84 views

Counter c1 = new Counter("ones"); c1.increment(); Counter c2 = c1; c2.increment(); StdOut.println(c1); class code link: https://introcs.cs.princeton.edu/java/33design/Counter.java public class ...
Clifford's user avatar
4 votes
1 answer
3k views

I am trying to understand what std::launder does, and I hoped that by looking up an example implementation it would be clear. Where can I find an example implementation of std::launder? When I ...
alfC's user avatar
  • 16.8k
0 votes
1 answer
105 views

Say I have a list called list, which is comprised of boolean values. Also say that I have some (valid) index i which is the index of list where I want to switch the value. Currently, I have: list[i] ...
user1519226's user avatar
-3 votes
1 answer
76 views

public void addToHead(IntNode node) { IntNode temp = _head; _head = node; node.setNext(temp); } edit:I searched youtube, Nothig there about linkedlist and the heap When does the garbage ...
Arik Shalito's user avatar
4 votes
3 answers
5k views

Is there a way to get an alias for a part of a list in python? Specifically, I want the equivalent of this to happen: >>> l=[1,2,3,4,5] >>> a=l >>> l[0]=10 >>> a [...
db_'s user avatar
  • 653
1 vote
1 answer
317 views

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 ...
user3673010's user avatar
1 vote
4 answers
2k views

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 ...
makansij's user avatar
  • 9,975
0 votes
4 answers
4k views

I'm trying to deal with aliases (friendly-urls) and probably I'm not doing it right. What I want to do is to transform urls like '/blog/my-post-about-something' into '/posts/23'. I have written a ...
carles's user avatar
  • 360
0 votes
1 answer
162 views

When running the function foo1, why does the output for this code will be: 15 30 5 and not 15 15 5 ? I underdtand that the pointer of the object v is now points to the object va1, so the output for ...
user3313599's user avatar
6 votes
3 answers
1k views

If dot_product is declared as float dot_product(const float* restrict a, const float* restrict b, unsigned n); would calling it with dot_product(x, x, x_len) be "undefined", according to the C99 ...
MWB's user avatar
  • 12.7k
2 votes
1 answer
323 views

The following query returns two different results on two instances of SQL Server 2008 R2: create table a(id int) insert into a(id) values(1) insert into a(id) values(2) select id, (select ...
user2598804's user avatar
0 votes
1 answer
50 views

I have a LINE class that has two attributes of type POINT (which is an object). public class LINE { private Point p1,p2; } If I make this statement, will it cause aliasing? public void setP1(Point ...
Assaf's user avatar
  • 1,124