Bug 38659 - Enhancement in _cpp_save_parameter
Summary: Enhancement in _cpp_save_parameter
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.6
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-29 07:45 UTC by huiwu
Modified: 2012-01-05 01:07 UTC (History)
0 users

See Also:
Host: linux-i386
Target: linux-i386
Build: i686-dell-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description huiwu 2008-12-29 07:45:18 UTC
In following definition of _cpp_save_parameter of v3.4.6 (It also can be found in v4.3.0)

1238 bool
1239 _cpp_save_parameter (cpp_reader *pfile, cpp_macro *macro, cpp_hashnode *node)
1240 {
       ...
1255   node->flags |= NODE_MACRO_ARG;
1256   len = macro->paramc * sizeof (union _cpp_hashnode_value);
1257   if (len > pfile->macro_buffer_len)
1258    {
1259       pfile->macro_buffer = xrealloc (pfile->macro_buffer, len);
1260       pfile->macro_buffer_len = len;
1261    }
1262   ((union _cpp_hashnode_value *) pfile->macro_buffer)[macro->paramc - 1]
    = node->value;
1263  
1264   node->value.arg_index  = macro->paramc;
1265   return false;
1266 }

Above line 1262 saves the value of cpp_hashnode by copying the struct, per my understanding it is because the hashnode will be used by other identifiers of same name in other following definitions, by saving the value, we can restore the node when needed. However, operation done at line 1264 can not be included by the copy, and in macro_buffer, arg_index is unset. Though currently, I can't find the place using this field, I also suggest to swap line 1264 and 1262.
Comment 1 Paolo Carlini 2012-01-05 01:07:23 UTC
If you are (still) interested in contributing improvements, please send patches to the appropriate gcc-patches mailing list. Thanks!