Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:29:05+00:00 2026-06-05T19:29:05+00:00

I have a quick question that I can’t seem to find online. I am

  • 0

I have a quick question that I can’t seem to find online.

I am using CUDA to do some GPU work, and I need some data allocated on the GPU. The cudaMalloc function goes like this:

cudaMalloc(void** identifier, size_t space);

Easy enough. So, let’s allocate an integer.

int i = 5;
cudaMalloc((void**)&(&i), sizeof(int));

But this errors (“expression must be an lvalue or a function designator”). The apparent workaround is to declare i as a pointer to begin with, and then take the address of it, and that works perfectly fine; I just hate workarounds.

I feel like this question should have an obvious answer – after all, the **, *** and even ********** work just fine in C. So, how do I get the address of the address of a variable ‘cleanly’?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:29:07+00:00Added an answer on June 5, 2026 at 7:29 pm

    That’s not a workaround; that’s the right way to do it.

    The function wants the address of a pointer to int, because it’s going to set that pointer to point to an int that it has just allocated. Therefore you need the address of a real, allocated pointer. An expression like “&&i” asks the compiler to give you the address of i — which is a pure number, with no storage location — and then give you a pointer to that value, which of course it can’t do.

    So you want to say

    int *p;
    cudaMalloc((void**)&p, sizeof(int));
    

    Now *p is the int that was allocated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question that I can't seem to find an answer for. If I am
A quick question, that I can't seem to find the answer to anywhere to
Just a quick simple question that I can not seem to find an answer
Quick question that I can't seem to find anywhere; at least not a clear
I have a quick question that I can't find anywhere. I am limiting my
I have a quick question here. I know that the cakePHP find('first') function returns
Quick question about include/requre_once . I have some code that is common to a
A quick technical question- I have two queries that output some of the same
I have a quick and hopefully simple question that I hope someone can help
Quick question: I have a saga that can have a scenario where it needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.