Tau G2 error message: dereferencing of NULL pointer.

Source: Internet
Author: User

The following error message is often encountered during Tau G2 programming:

********************** ****** Error **************************

Dereferencing of NULL pointer.

Pointer assigned new data area at address.

It is necessary to describe it in detail.

Generally, this problem occurs when accessing a class or structure variable. For example, the following is a program snippet.

D_attach_detach_group_identity d_attach_detach_group_identity_type;

Group_identity_downlink group_identity_downlink_type;

Group_identity_downlinks group_identity_downlinks_type;

Carray <group_identity_downlink, 63> data;

D_attach_detach_group_identity_type.pdu_type = 10;

D_attach_detach_group_identity_type.group_identity_report = false;

D_attach_detach_group_identity_type.group_identity_acknowlegement = true;

D_attach_detach_group_identity_type.group_identity_attach_detach_mode = true;

D_attach_detach_group_identity_type.o_bit = true;

D_attach_detach_group_identity_type.m_bit = true;

Group_identity_downlink_type.is_giadti_present = true;

Group_identity_downlink_type.giadti = detach;

Group_identity_downlink_type.group_id_attach_or_detach.group_id_detachment_downlink = 3;

Group_identity_downlink_type.is_giat_present = true;

Group_identity_downlink_type.giat = gssi;

Group_identity_downlink_type.group_id_address.group_short_subscriber_identity = 1;

D_attach_detach_group_identity_type.group_identity_downlinks.data [0] = group_identity_downlink_type;

D_attach_detach_group_identity_type.group_identity_downlinks.noofrepeatedelements = 1;

 
In this program, access d_attach_detach _Group_identity _Type, Group_identity _Downlink _TypeAnd group_identity _Downlinks _TypeErrors are reported when the three variables are members. Although this error can be ignored to continue running, it is very troublesome if there are many errors. Why is this error?

The main reason is that in Tau G2, class or struct variables are treated as pointers. If you look at these variables in the watch window, they are all null before accessing the variables, the address of the variable is displayed after the value is assigned, which is basically the same as that of the C language for pointer variables. Therefore, when assigning values to these variables for 1st times, the system reports the access NULL pointer. To avoid this problem, use the new keyword to allocate space before assigning values. For example:

Carray <group_identity_downlink, 63> data;

D_attach_detach_group_identity_type = new d_attach_detach_group_identity ();

Group_identity_downlink_type = new group_identity_downlink ();

D_attach_detach_group_identity_type.pdu_type = 10;

D_attach_detach_group_identity_type.group_identity_report = false;

D_attach_detach_group_identity_type.group_identity_acknowlegement = true;

D_attach_detach_group_identity_type.group_identity_attach_detach_mode = true;

......

This prevents such problems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.