Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000412OCamlCamlIDLpublic2001-06-27 17:052001-07-30 09:30
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000412: camlidl and size_is attribute
DescriptionFull_Name: Dmitry Bely
Version: 3.01, camlidl cvs 27.06.01
OS: Windows NT 4.0
Submission from: d009.p3.col.ru (195.210.132.9)


"size_is" attribute is handled wrong for typedefs:

typedef struct {
    int len;
    [size_is(len)] int* data; /* OK */
} STRUCT1;

typedef int* PINT;
typedef struct {
    int len;
    [size_is(len)] PINT data; /* Warning: attribute `size_is' unknown, malformed
or not applicable here, ignored. */
} STRUCT2;

This is like the "string" attribute problem I reported before.

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000042)
administrator (administrator)
2001-06-29 10:13

> "size_is" attribute is handled wrong for typedefs:
>
> typedef struct {
> int len;
> [size_is(len)] int* data; /* OK */
> } STRUCT1;
>
> typedef int* PINT;
> typedef struct {
> int len;
> [size_is(len)] PINT data;
> /* Warning: attribute `size_is' unknown, malformed
> or not applicable here, ignored. */
> } STRUCT2;

For Camlidl, a "typedef" is not a macro -- it's a real declaration
that causes conversion functions for the defined type to be generated.
From this standpoint, it makes no sense to modify the type a posteriori
with a size_is attribute. In other terms, [size_is(...)] is
syntactically part of an array or pointer type
        [size_is(...)] ty * foo
or
        [size_is(...)] ty foo[]
but cannot be applied a posteriori to a named pointer or array type.

The MIDL spec isn't too clear about this, but all the examples it shows
are of the two forms above.

> This is like the "string" attribute problem I reported before.

It's subtly different: your example was

        typedef char MYCHAR;
        [string] MYCHAR * x;

Here [string] is part of a pointer type expression, so it can be
parsed correctly as a string type.

- Xavier Leroy

(0000043)
administrator (administrator)
2001-06-29 10:31

Normal behavior.
(0000044)
administrator (administrator)
2001-06-29 12:31

Xavier Leroy <Xavier.Leroy@inria.fr> writes:

> > "size_is" attribute is handled wrong for typedefs:
> >
> > typedef struct {
> > int len;
> > [size_is(len)] int* data; /* OK */
> > } STRUCT1;
> >
> > typedef int* PINT;
> > typedef struct {
> > int len;
> > [size_is(len)] PINT data;
> > /* Warning: attribute `size_is' unknown, malformed
> > or not applicable here, ignored. */
> > } STRUCT2;
>
> For Camlidl, a "typedef" is not a macro -- it's a real declaration
> that causes conversion functions for the defined type to be generated.
> From this standpoint, it makes no sense to modify the type a posteriori
> with a size_is attribute. In other terms, [size_is(...)] is
> syntactically part of an array or pointer type
> [size_is(...)] ty * foo
> or
> [size_is(...)] ty foo[]
> but cannot be applied a posteriori to a named pointer or array type.
>
> The MIDL spec isn't too clear about this, but all the examples it shows
> are of the two forms above.

Unfortunately, all examples are taken from the real Microsoft sources
(wtypes.idl):

typedef struct _SECURITY_ATTRIBUTES {
    DWORD nLength;
    [size_is(nLength)] LPVOID lpSecurityDescriptor;
    BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;

OK, Microsoft docs has never been accurate, so you can mark it as "not a
bug" -- anyway I can edit that manually, inserting necessary #ifs.

Hope to hear from you soon,
Dmitry



- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker