[Bug c/44179] warn about sizeof(char) and sizeof('x')

2023-12-15 Thread zack+srcbugz at owlfolio dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44179

--- Comment #3 from Zack Weinberg  ---
It's come to my attention that people fairly often write `sizeof('x')` (or some
other character constant), _expecting_ it to evaluate as `sizeof(char)`.  But
this is only true in C++. In C, `sizeof('x')` evaluates as `sizeof(int)`.

See
http://codesearch.debian.net/search?q=filetype%3Ac+%5Cbsizeof%5Cs*%5C%28%5Cs*%27=0
for many examples.

It's probably more important to warn about this than about `sizeof(char)`
itself.

[Bug testsuite/108675] FAIL: gcc.c-torture/execute/builtins/*printf.c when stdio.h includes definitions

2023-02-06 Thread zack+srcbugz at owlfolio dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108675

--- Comment #6 from Zack Weinberg  ---
Note that what you (mingw) have in this header is a pretty serious
anti-optimization.  Functions that call __builtin_va_start cannot be inlined
under any circumstances whatsoever (try tagging it
__attribute__((always_inline)) and see what happens) so you're emitting a
redundant copy of this function in every translation unit that calls fprintf,
and you're not getting any actual codegen improvement in exchange.

You _could_ do like glibc bits/stdio2.h

__mingw_ovr
__attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
int printf (const char *__format, ...)
{
  return __mingw_fprintf(stdout, __format, __builtin_va_arg_pack());
}

but this doesn't let you synthesize a direct call to __mingw_vfprintf.

I'd recommend scrapping the entire mess, abandoning the idea of getting direct
calls to v*printf/v*scanf, and using asm() symbol renaming to add the __mingw_
prefix.  That should also avoid stepping on the GCC testcases' toes.

[Bug c++/41233] Templated conversion operator produces symbol name that won't demangle

2022-11-20 Thread zack+srcbugz at owlfolio dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41233

--- Comment #10 from Zack Weinberg  ---
The examples found by other people still don't demangle, though...

$ c++filt --version 2>&1 | head -n1
GNU c++filt (GNU Binutils for Debian) 2.39
$ c++filt <<\EOF
_ZNK3FooIPvEcvS_IT_EIiEEv
_ZN5vnullcv3vecIT_T0_T1_EI10double_int7va_heap6vl_ptrEEv
EOF
_ZNK3FooIPvEcvS_IT_EIiEEv
_ZN5vnullcv3vecIT_T0_T1_EI10double_int7va_heap6vl_ptrEEv