[Bug c/108964] New: Attribute target should be implemented for C backend (not only c++)

2023-02-28 Thread rouca at debian dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108964

Bug ID: 108964
   Summary: Attribute target should be implemented for C backend
(not only c++)
   Product: gcc
   Version: 12.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rouca at debian dot org
  Target Milestone: ---

Hi,

The following program fail to compile with gcc but compile with g++

On the debian side we will like to have it see
https://wiki.debian.org/InstructionSelection

__attribute__((target("default")))
int test_fn()
{
return 1;
}

__attribute__((target("sse2")))
int test_fn()
{
return 0;
}


int main()
{
return test_fn();
}

Bastien (rouca for debian)

[Bug c/109214] New: extension to C language allowing void * to be cast to function pointer should be documented

2023-03-20 Thread rouca at debian dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109214

Bug ID: 109214
   Summary: extension to C  language allowing void  * to be cast
to function pointer should be documented
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rouca at debian dot org
  Target Milestone: ---

Hi,

according to POSIX
https://pubs.opengroup.org/onlinepubs/009696899/functions/dlsym.html

"The ISO C standard does not require that pointers to functions can be cast
back and forth to pointers to data. Indeed, the ISO C standard does not require
that an object of type void * can hold a pointer to a function. Implementations
supporting the XSI extension, however, do require that an object of type void *
can hold a pointer to a function. The result of converting a pointer to a
function into a pointer to another data type (except void *) is still
undefined, however. Note that compilers conforming to the ISO C standard are
required to generate a warning if a conversion from a void * pointer to a
function pointer is attempted as in:

fptr = (int (*)(int))dlsym(handle, "my_function");"

This extension should be documented in the C, C++ extension documentation.

Moreover maybe adding a type attribute in order to clear the warning for this
kind of function may also help [1]

Bastien

[1] https://stackoverflow.com/questions/31526876/casting-when-using-dlsym

[Bug c/109214] extension to C language allowing void * to be cast to function pointer should be documented

2023-03-20 Thread rouca at debian dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109214

--- Comment #1 from rouca  ---
According to my C standard:


  6.3.2.3 Pointers
1 A pointer to void may be converted to or from a pointer to any incomplete
or object
type. A pointer to any incomplete or object type may be converted to a
pointer to void
and back again; the result shall compare equal to the original pointer.
[...]
8. A pointer to a function of one type may be converted to a pointer to a
function ofanother
  type and back again; the result shall compare equal to the original
pointer. If a converted
  pointer is used to call a function whose type is not compatible with the
pointed-to type,
  the behavior is undefined


Note that I work due to implementation of J - Portability issues, §J.5.7
Function pointer cast (informative)

J.5.7 Function pointer casts
1 A pointer to an object or to void may be cast to a pointer to a function,
allowing data to
be invoked as a function (6.5.4).
2 A pointer to a function may be cast to a pointer to an object or to void,
allowing a
function to be inspected or modified (for example, by a debugger) (6.5.4).

[Bug c/108964] Attribute target should be implemented for C backend (not only c++)

2023-06-22 Thread rouca at debian dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108964

rouca  changed:

   What|Removed |Added

Version|12.2.0  |14.0

--- Comment #1 from rouca  ---
Hi,

On the debian side we will really like to have it.