[ 
https://issues.apache.org/jira/browse/TS-125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12834041#action_12834041
 ] 

John Plevyak commented on TS-125:
---------------------------------

Just checked the C++ spec, and it sees that a conformant
compiler need only give the correct result for offset of
for POD types despite the fact that only a few features,
virtual base classes in particular, cause problems for
it. 

g++ was kind enough to not be pedantic about
it and just make it work for all the normal cases.

SunCC seems to have decided to take advantage
of the spec (and developers) and just throw an
error even if it could deliver the offset at compile time.

This could be worked around via some C++/template
hijinks which would encoded the offset via a template
parameter class with a single functions, yada yada,
thus moving the constant into a function call which
presumably the optimizer would inline and which
would result in the same code.

I suppose it is too much to hope that the C++ committee
will pull their head out and realize that if folks really
wanted to use a high level language they would be using
scala or F#  or something and that they should leave the
low level functionality in C++ alone

 

> Cannot use user-defined types in typedef of template function
> -------------------------------------------------------------
>
>                 Key: TS-125
>                 URL: https://issues.apache.org/jira/browse/TS-125
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Portability
>         Environment: OpenSolaris with SunStudio (gcc on opensolaris fails the 
> same code with a different error; same workaround fixes it)
>            Reporter: Nick Kew
>            Priority: Critical
>
> This appears to be related to Sun bug 
> http://bugs.sun.com/view_bug.do?bug_id=6906118
> but is sufficiently different that the workaround suggested there doesn't 
> apply.
> Compiling DAllocator.h produces the following fatal error:
> "DAllocator.h", line 86: Error: Unexpected type name "AllocPoolDescriptor" 
> encountered.
> "DAllocator.h", line 87: Error: Unexpected type name "AllocDescriptor" 
> encountered.
> It can be worked around by reverting:
> @@ -83,8 +83,8 @@
>    int alignment;
>    int el_size;
>  
> -  SList(AllocPoolDescriptor,link) pools;
> -  Que(AllocDescriptor,link) free_list;
> +  SLL<AllocPoolDescriptor> pools;
> +  Queue<AllocDescriptor> free_list;
> Expanding that with the -E option to CC reveals that this loses an offsetof 
> argument, so if we could fix the offset to zero then the problem goes away.  
> If at all possible, it would be good to make "link" the first element of 
> AllocDescriptor and AllocPoolDescriptor so the need for offsetof goes away.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to