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

  • SEARCH
  • Home
  • 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 8647477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:04:59+00:00 2026-06-12T13:04:59+00:00

I have a to deal with a structure of a lib : typedef struct

  • 0

I have a to deal with a structure of a lib :

typedef struct {
   uint8_t   response_type;
   uint8_t   error_code;
   uint16_t sequence;
   uint32_t resource_id;
   uint16_t minor_code;
   uint8_t major_code;
   uint8_t pad0;
   uint32_t pad[5];
   uint32_t full_sequence;
} a_structure;

my problem come from the pad[5] member of the structure that I don’t really understand.
I thougth this member can be used as the other member in function like that:

uint8_t get_response_type( a_structure * my_struct)
{
   return my_struct->response_type;
}

but this function:

uint32_t get_pad_5( a_structure * my_struct)
{
   return my_struct->pad[5];
}

generate warning in gcc

error array subscript is above array bounds

Can someone explain me what this means ?

Thxs

  • 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-12T13:05:00+00:00Added an answer on June 12, 2026 at 1:05 pm

    Structure field pad was defined as “array of 5 uint32_t“. You must differ variable definition from using the variable. So since pad is defined, pad[5] means “get the fifth (counting from 0) element of pad array”. But there is no such element in pad array, because the highest index available for this array is 4.

    Also, it seems that you want to return pointer to the first element of this array, not the fifth element. So you must rewrite your function this way:

    uint32_t * get_pad_5( a_structure * my_struct)
    {
        return my_struct->pad;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example in C I have structure: typedef struct { int number; double x1;
basically i have this structure: Deal has and belongs to many Channels Deal has
I have to deal with an API which need to be provided a DataSource
I have a deal with a 3rd party web page. And If I click
I do have to deal with very large plain text files (over 10 gigabytes,
I often have to deal with XML documents that contain namespaced elements, but doesn't
The active directory I have to deal with is laid out as such: the
I have bits of horrible code I have to deal with ... <div class=container>
in a rails project i have to deal with lots of strings, that are
I am using java and have to deal with numbers larger than long (which

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.