Skip to content

clang does not implement __assume__ attribute, fails libstdc++ build #71858

@trofi

Description

@trofi

gcc implements __assume__ attribute as: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html, quoting the example:

int foo (int x, int y) { __attribute__((assume(x == 42))); __attribute__((assume(++y == 43))); return x + y; }

clang-16 fails to build it as:

$ clang -c a.c a.c:4:18: error: 'assume' attribute cannot be applied to a statement __attribute__((assume(x == 42))); ^ ~ a.c:5:18: error: 'assume' attribute cannot be applied to a statement __attribute__((assume(++y == 43))); ^ ~ 2 errors generated. 

Recently gcc started using it in libstdc++ https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e39b3e02c27bd7 as

 void _M_assume_normalized() const { unsigned int __ofst = _M_offset; __attribute__ ((__assume__ (__ofst < unsigned(_S_word_bit)))); }

and clang++ now fails to parse <vector> from libstdc++.

Is there a change clang would support this style of __assume__ attribute or at least skipped it in stead of producing build failure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"extension:gnu

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions