}
else if (tree_int_cst_lt (maxobjsize, args[i]))
{
- /* G++ emits calls to ::operator new[](SIZE_MAX) in C++98
- mode and with -fno-exceptions as a way to indicate array
- size overflow. There's no good way to detect C++98 here
- so avoid diagnosing these calls for all C++ modes. */
+ /* G++ emits calls to ::operator new[](SIZE_MAX) in C++98 mode or
+ with -fno-exceptions as a way to indicate array size overflow.
+ Avoid diagnosing these calls. Additionally, see e.g. PR99934,
+ G++ also potentially generates such calls in C++11 and later as
+ well, so suppress the diagnostic in all C++ modes. */
if (i == 0
&& fn
&& !args[1]
- && lang_GNU_CXX ()
&& DECL_IS_OPERATOR_NEW_P (fn)
&& integer_all_onesp (args[i]))
continue;
--- /dev/null
+/* PR tree-optimization/106409 */
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto -W -Wall -O2 -fno-exceptions } { -flto -W -Wall -O2 -std=c++98 } { -flto -W -Wall -O2 -std=gnu++20 } } } */
+struct bb
+{
+ int t;
+ int t1;
+ int t2;
+ int t3;
+};
+
+[[gnu::noipa]]
+void *f(unsigned long paramCount)
+{
+ if (paramCount == 0)
+ return 0;
+ return new bb[paramCount]();
+}
+
+int main(void)
+{
+ f(100);
+}