https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117810

            Bug ID: 117810
           Summary: Feature request: attribute access but for (start, end)
                    type interfaces
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix-gcc at fefe dot de
  Target Milestone: ---

I love attribute access, I use it all the time in my projects.

You can tell the compiler that the function reads n elements from a pointer,
and n is given as a function argument.

But not all functions work like that. In fact, C++ iterators don't.
My LDAP code also doesn't. It looks like this:

size_t scan_asn1BOOLEAN(const char* src,const char* max,int* l);

Instread of src and len I pass src and max. The reasoning is that you will use
these functions to iterate over multiple serialized elements. The common
pattern for that will be to move the pointer forward until you hit the end. If
I pass a length, then the caller would have to decrement the length, too. That
is a burden the caller does not need to carry, so I'm trying to relieve them of
it.

Unfortunately attribute access does not work because since I can't point it to
a length, I can only express that I will read one byte from src, which is not
true. It might in fact be wrong because if src == max then I won't be reading
anything.

Please extend attribute access to also work if the second argument given is not
an int but another pointer of the same type. Or you could give me a new
attribute doing the same thing under another name for backwards compatibility.
I don't care. I just want to be able to annotate my code properly.

Reply via email to