Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0009915 [GCC-XML] major always 2009-11-18 06:40 2009-11-18 16:49
Reporter gjcarneiro View Status public  
Assigned To brad.king
Priority normal Resolution suspended  
Status closed  
Summary 0009915: parameter default value parsed wrong with template class
Description A simple constructor:

  Test (Time lifetime = MilliSeconds (0));

In this case, MilliSeconds is a function that returns Time, which is a templated instantiation class. GCC-XML reports the default value as default="MilliSeconds(uint64_t)()", which is clearly wrong. After going through pygccxml, what I get is MilliSeconds().
Additional Information A bug I found in NS-3 (www.nsnam.org) Python bindings.

To reproduce, parse the attached test file:

$ gccxml -I . -fxml=/tmp/test.xml test.h
$ grep /tmp/test.xml -e Constructor -A10 |grep Milli
    <Argument name="lifetime" type="_89" location="f2:21" file="f2" line="21" default="MilliSeconds(uint64_t)()"/>

Tags No tags attached.
Attached Files ? file icon test.h [^] (354 bytes) 2009-11-18 06:40

- Relationships

-  Notes
(0018478)
roman.yakovenko (reporter)
2009-11-18 15:28
edited on: 2009-11-18 15:33

In order to dump right a default argument, GCCXML has to implement the following algorithm:

* split the default argument expression to identifiers
* resolve every identifier ( find out fully qualified name )
* re-write the expression using fully qualified identifiers


This is a huge amount of work and I am not sure it worse it. After all, the work around is easy

* ask the user to create a new function overload
* ask the user to specify the default argument expression in a code generator.

pygccxml uses second approach and many users seems to be happy with it, once they understand the complexity of the task.


In pygccxml package, I implemented few work-around's to the problem:
* resolve enum value:
* remove double call
  - if written x()() pygccxml will replace it with x()
* fix invalid integers
  - if the argument type is "int" and default value is [abcdef][0-9] then add 0x to the expression
* sometimes the default value expression is a call to the argument type constructor
  - pygccxml will resolve the constructor identifier

I am pretty sure, that GCCXML should NOT implement any of them. The partial solution will only confuse the users more.

(0018483)
brad.king (manager)
2009-11-18 16:48

Thanks, Roman.

So, the problem is that the original user-specified default expression is simply lost by the time our XML dump code sees it. The default argument attribute in the XML is printed by gcc's expression dump code. That code is normally used just to print diagnostics, so it is not intended to create an expression that will re-parse correctly. Generating an expression that re-parses correctly is a very difficult problem in C++.

- Issue History
Date Modified Username Field Change
2009-11-18 06:40 gjcarneiro New Issue
2009-11-18 06:40 gjcarneiro File Added: test.h
2009-11-18 15:28 roman.yakovenko Note Added: 0018478
2009-11-18 15:33 roman.yakovenko Note Edited: 0018478
2009-11-18 16:41 brad.king Status new => assigned
2009-11-18 16:41 brad.king Assigned To => brad.king
2009-11-18 16:48 brad.king Note Added: 0018483
2009-11-18 16:49 brad.king Status assigned => closed
2009-11-18 16:49 brad.king Resolution open => suspended


Mantis 1.1.4[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker