[Bug tree-optimization/111517] [12/13 Regression] Optimization -O1 removes necessary loop for initialization since r12-5915-ge93809f62363ba

2023-09-22 Thread aegges at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111517

--- Comment #6 from Axel Mueller  ---
I can confirm that the code now works with trunk version on godbolt.
Thanks for the quick analysis (and of course the fix). Looking forward to the
12.4 fix release.

[Bug c++/111517] New: Optimization -O1 removes necessary loop for initialization

2023-09-21 Thread aegges at web dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111517

Bug ID: 111517
   Summary: Optimization -O1 removes necessary loop for
initialization
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aegges at web dot de
  Target Milestone: ---

We have found a regression in gcc 12 (and later) in comparison to gcc 11 (and
clang) which occurs if optimization (at least -O1) is enabled.
In the following C++ code the member variables a1 and e1 are initialized in a
loop in a init() method which is called in the constructor.  

#include 
#include 

class TestClass
{
public:
   TestClass()
   { 
   for(int i=0; i<20; i++)
   {
  a1[i] = i;
   }

   init();
}

void init();
unsigned int a1[20];
unsigned char e1[20][20];
};

void TestClass::init()
{
for (int b1 = 0; b1 < 20; b1++)
{
for (int b2 = 0; b2 < 20; b2++)
{
e1[b1][b2] = a1[b2];
}
}
}

TestClass tmp;

int main()
{
for(int i=0; i < 20 ; i++)
std::cout << std::to_string(tmp.e1[i][i]) << " ";
}
expected output: (gcc <= 11 or gcc >=12 w/o optimization)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

actual output: 8gcc >=12 with optimization)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 


I have used godbolt to verify the different behavior (see
https://godbolt.org/z/MnoPE8Yfr )

[Bug libmudflap/30994] App using Qt lib aborts immediately during startup

2012-01-19 Thread aegges at web dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30994

Axel Mueller  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #2 from Axel Mueller  2012-01-19 11:12:21 UTC 
---
(In reply to comment #1)
> From the sound of it, libmudflap is not being initialized before QT is.  QT is
> calling malloc in its initialization and malloc returns NULL.
You are my hero 
I did not expect to get an answer after 5 years. And I did not expect to get a
helpful answer.

I changed to link order from
LIBS = -lQtCore -lmudflapth
to 
LIBS = -lmudflapth -lQtCore

Thus mudflap is the last in the line and will get linked/loaded first.
Now everything works as expected. Therefore, I will close this bug.

Thank you very much.


Just for the record.
To use Mudflap with Qt you have to add the following lines to your .pro file
(Qt project file):
QMAKE_CXXFLAGS += -fmudflapth
QMAKE_CFLAGS += -fmudflapth
# do not use QMAKE_LIBS for mudflap; private libs will be loaded before Qt
LIBS_PRIVATE += -lmudflapth


[Bug libmudflap/30994] New: App using Qt lib aborts immediately during startup

2007-02-28 Thread aegges at web dot de
I compiled a simple app that is linked dynamically against the Qt library (Qt
3.3.8). 

#include "qstring.h"
int main(void) {
   QString oTmp("Hello world");

   printf( "%s\n", oTmp.ascii() );
   return 1;
}

I have compiled the source file with mudflap activated. When I start the
program I get the following error:
terminate called after throwing an instance of 'St9bad_alloc'
  what():  St9bad_alloc
Aborted.

The backtrace of gdb gives:
#0  0xb7f51410 in __kernel_vsyscall ()
#1  0x43517aed in raise () from /lib/libc.so.6
#2  0x43519239 in abort () from /lib/libc.so.6
#3  0xb7599a90 in __gnu_cxx::__verbose_terminate_handler ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#4  0xb75977c5 in ?? () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#5  0xb75977f6 in std::terminate ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#6  0xb75978fa in __cxa_throw () from
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#7  0xb7597ce0 in operator new ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#8  0xb7597da9 in operator new[] ()
   from /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6
#9  0xb7b8d144 in qstrdup ()
   from /home/amueller/sources/qt-x11-commercial-3.3.8/lib/libqt-mt.so.3
#10 0xb7ba2200 in QGDict::look_ascii ()
   from /home/amueller/sources/qt-x11-commercial-3.3.8/lib/libqt-mt.so.3
#11 0xb78484f7 in QMetaObjectCleanUp::QMetaObjectCleanUp ()
   from /home/amueller/sources/qt-x11-commercial-3.3.8/lib/libqt-mt.so.3
#12 0xb7c79764 in global constructors keyed to
_ZNK15QMotifPlusStyle9classNameEv ()
   from /home/amueller/sources/qt-x11-commercial-3.3.8/lib/libqt-mt.so.3

Using MUDFLAP_OPTIONS did not help as my app doesn't seem to reach the point
where it evaluates MUDFLAP_OPTIONS, as even MUDFLAP_OPTIONS="-help" doesn't
work.

The interesting thing is that I can run the mudflapped app with valgrind!!! 

Gentoo Linux 2.6.18, gcc 4.1.2 (identical problem with gcc 4.1.1)


-- 
   Summary: App using Qt lib aborts immediately during startup
   Product: gcc
   Version: 4.1.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libmudflap
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aegges at web dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30994