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

--- Comment #1 from Sam James <sam at gentoo dot org> ---
Minimised reproducer works with Clang but fails with GCC 12 w/ F_S=3:

qt.cxx:
```
extern "C" void __readlink_chk(char *, char *, long, long);
char readlink___path, readlink___buf;
namespace Qt {
enum Initialization {} Uninitialized;
}
struct QArrayData {
  int size;
};
struct QByteArray {
  QByteArray(int, Qt::Initialization);
  ~QByteArray();
  int size() const;
  QArrayData d;
};
QByteArray::~QByteArray() {}
int QByteArray::size() const { return d.size; }
main() {
  QByteArray buf(6, Qt::Uninitialized);
  int __trans_tmp_1 = buf.size();
  __readlink_chk(&readlink___path, &readlink___buf, __trans_tmp_1, 0);
}
```

```
$ c++ -O2 -D_FORTIFY_SOURCE=3 -l Qt5Core qt.cxx -o qt
qt.cxx:17:1: warning: ISO C++ forbids declaration of ‘main’ with no type
[-Wreturn-type]
   17 | main() {
      | ^~~~
$ ./qt
*** buffer overflow detected ***: terminated
Aborted (core dumped)
```

Reply via email to