[Bug c/39661] New: segmentation failed on correctly compiled mixed C and C++ code

2009-04-06 Thread pavel dot petrovic at gmail dot com
I understand C is low-level, but I'd love the compiler to refuse to compile or
link a mixed C and C++ code that is not mixed correctly.

The story is: parts of the program are implemented in C, parts are in C++. The
functions in C++ are made callable from C using the "__attribute__((stdcall))"
feature, i.e. these are C-type functions implemented in C++. The main program
is in C, and attempts to call these functions, which further call


-- 
   Summary: segmentation failed on correctly compiled mixed C and
C++ code
   Product: gcc
   Version: 4.2.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: pavel dot petrovic at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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



[Bug c/39662] New: segmentation failed on correctly compiled mixed C and C++ code

2009-04-06 Thread pavel dot petrovic at gmail dot com
ing nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.4/include
 /usr/include
End of search list.
 /usr/lib/gcc/i486-linux-gnu/4.2.4/cc1 -fpreprocessed fnmc.i -quiet -dumpbase
fnmc.c -mtune=generic -auxbase fnmc -g -version -fstack-protector
-fstack-protector -o fnmc.s
GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu3) (i486-linux-gnu)
compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu3).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128358
Compiler executable checksum: e2971cf2189271aeeb10133511ecea3a
 as --traditional-format -V -Qy -o fnmc.o fnmc.s
GNU assembler version 2.18.0 (i486-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.18.0.20080103
g++ -v -save-temps -o fn3 fnc.o fnmc.o -g
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
 /usr/lib/gcc/i486-linux-gnu/4.2.4/collect2 --eh-frame-hdr -m elf_i386
--hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o fn3
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.2.4/crtbegin.o
-L/usr/lib/gcc/i486-linux-gnu/4.2.4 -L/usr/lib/gcc/i486-linux-gnu/4.2.4
-L/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.2.4/../../.. fnc.o fnmc.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i486-linux-gnu/4.2.4/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crtn.o
petro...@student03:~/pasCPP2$ ./fn3 
f2(2,3)=5
exiting...
Segmentation fault
petro...@student03:~/pasCPP2$

--
I understand, I am probably doing the mixing of C and C++ incorrectly, although
I am not sure where (hints are welcome!), but still, would it be possible to
get the compiler/linker to produce a warning, if it is generating a code that
crashes? 

P.S. sorry for my previous unfinished post (accidentally clicked ENTER before
finishing the report)


-- 
   Summary: segmentation failed on correctly compiled mixed C and
C++ code
   Product: gcc
   Version: 4.2.4
    Status: UNCONFIRMED
      Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pavel dot petrovic at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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



[Bug c/39662] segmentation failed on correctly compiled mixed C and C++ code

2009-04-06 Thread pavel dot petrovic at gmail dot com


--- Comment #1 from pavel dot petrovic at gmail dot com  2009-04-06 12:23 
---
Created an attachment (id=17594)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17594&action=view)
archive with all sources, and i. .ii, .s files


-- 


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



[Bug c/39662] segmentation failed on correctly compiled mixed C and C++ code

2009-04-06 Thread pavel dot petrovic at gmail dot com


--- Comment #2 from pavel dot petrovic at gmail dot com  2009-04-06 12:28 
---
*** Bug 39661 has been marked as a duplicate of this bug. ***


-- 


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



[Bug c/39661] segmentation failed on correctly compiled mixed C and C++ code

2009-04-06 Thread pavel dot petrovic at gmail dot com


--- Comment #1 from pavel dot petrovic at gmail dot com  2009-04-06 12:28 
---


*** This bug has been marked as a duplicate of 39662 ***


-- 

pavel dot petrovic at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||DUPLICATE
Summary|segmentation failed on  |segmentation failed on
   |correctly compiled mixed C  |correctly compiled mixed C
   |and C++ code|and C++ code


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



[Bug target/31644] [avr] can't find a register in class 'BASE_POINTER_REGS' while reloading 'asm'

2007-07-28 Thread pavel dot petrovic at gmail dot com


--- Comment #4 from pavel dot petrovic at gmail dot com  2007-07-28 20:24 
---
This bug is quite cruel. I have similar application, also for atmega168 and
WinAVR (avr-gcc (GCC) 4.1.2 (WinAVR 20070525)), and the following lines do not
compile giving the same error. Even worse, if the code is with for-loop, it
compiles, but it crashes when the variable is accessed, or it overwrites
it with a value of a different variable (that is not very neighboring one).

  //load calibrated values from eeprom  
  left_ir_min = eeprom_read_word((uint16_t*)0);
  left_ir_center = eeprom_read_word((uint16_t*)2);
  left_ir_max = eeprom_read_word((uint16_t*)4);
  right_ir_min = eeprom_read_word((uint16_t*)6);
  right_ir_center = eeprom_read_word((uint16_t*)8);
  right_ir_max = eeprom_read_word((uint16_t*)10);

  left_rot[0] = eeprom_read_word((uint16_t*)12);
  right_rot[0] = eeprom_read_word((uint16_t*)14);
  left_rot[1] = eeprom_read_word((uint16_t*)16);
  right_rot[1] = eeprom_read_word((uint16_t*)18);
  left_rot[2] = eeprom_read_word((uint16_t*)20); 
  /* any of the following lines, if present, cause compiler to fail */
  right_rot[2] = eeprom_read_word((uint16_t*)22); 
  left_rot[3] = eeprom_read_word((uint16_t*)24); 
  right_rot[3] = eeprom_read_word((uint16_t*)26); 


-- 

pavel dot petrovic at gmail dot com changed:

   What|Removed |Added

 CC||pavel dot petrovic at gmail
   ||dot com


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



[Bug c/39662] segmentation failed on correctly compiled mixed C and C++ code

2009-04-22 Thread pavel dot petrovic at gmail dot com


--- Comment #4 from pavel dot petrovic at gmail dot com  2009-04-23 06:06 
---
Thanks! it works. I was confused by this document:
ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf which seems to
claim the opposite.


-- 

pavel dot petrovic at gmail dot com changed:

   What|Removed |Added

 CC||pinskia at gcc dot gnu dot
   ||org


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



[Bug c++/21393] New: Internal error: Segmentation Fault (program cc1plus) on a very long cout << ... << command

2005-05-04 Thread pavel dot petrovic at gmail dot com
Here is what happens, the program ola2.cpp and ola2.ii are
available from http://www.idi.ntnu.no/~petrovic/ola2.zip

--
furu$ g++ -v -save-temps -o ola2 ola2.cpp -O3 -Wall
Reading specs from /store/lib/gcc/sparc-sun-solaris2.9/3.4.3/specs
Configured with: /stores/stash/gcc/src-3.4.3-local/gcc-3.4.3/configure --with-
local-prefix=/store --prefix=/store --with-included-gettext --with-
libiconv=/store/lib
Thread model: posix
gcc version 3.4.3
 /store/libexec/gcc/sparc-sun-solaris2.9/3.4.3/cc1plus -E -quiet -v -
iprefix /stores/idislave/.gcc/ver-3.4.3/bin/../lib/gcc/sparc-sun-
solaris2.9/3.4.3/ ola2.cpp -mcpu=v7 -Wall -O3 -o ola2.ii
ignoring nonexistent directory "/stores/idislave/.gcc/ver-
3.4.3/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.3/../../../../include/c++/3.4.3"
ignoring nonexistent directory "/stores/idislave/.gcc/ver-
3.4.3/bin/../lib/gcc/sparc-sun-
solaris2.9/3.4.3/../../../../include/c++/3.4.3/sparc-sun-solaris2.9"
ignoring nonexistent directory "/stores/idislave/.gcc/ver-
3.4.3/bin/../lib/gcc/sparc-sun-
solaris2.9/3.4.3/../../../../include/c++/3.4.3/backward"
ignoring nonexistent directory "/stores/idislave/.gcc/ver-
3.4.3/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.3/include"
ignoring nonexistent directory "/stores/idislave/.gcc/ver-
3.4.3/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.3/../../../../sparc-sun-
solaris2.9/include"
ignoring nonexistent directory "/store/lib/gcc/sparc-sun-
solaris2.9/3.4.3/../../../../sparc-sun-solaris2.9/include"
#include "..." search starts here:
#include <...> search starts here:
 /store/lib/gcc/sparc-sun-solaris2.9/3.4.3/../../../../include/c++/3.4.3
 /store/lib/gcc/sparc-sun-solaris2.9/3.4.3/../../../../include/c++/3.4.3/sparc-
sun-solaris2.9
 /store/lib/gcc/sparc-sun-
solaris2.9/3.4.3/../../../../include/c++/3.4.3/backward
 /store/include
 /store/lib/gcc/sparc-sun-solaris2.9/3.4.3/include
 /usr/include
End of search list.
 /store/libexec/gcc/sparc-sun-solaris2.9/3.4.3/cc1plus -fpreprocessed ola2.ii -
quiet -dumpbase ola2.cpp -mcpu=v7 -auxbase ola2 -O3 -Wall -version -o ola2.s
GNU C++ version 3.4.3 (sparc-sun-solaris2.9)
compiled by GNU C version 3.4.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
g++: Internal error: Segmentation Fault (program cc1plus)
Please submit a full bug report.
See http://gcc.gnu.org/bugs.html> for instructions.
--

-- 
   Summary: Internal error: Segmentation Fault (program cc1plus) on
a very long cout << ... << command
   Product: gcc
   Version: 3.4.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
     Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pavel dot petrovic at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org


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


[Bug c++/21393] Internal error: Segmentation Fault (program cc1plus) on a very long cout << ... << command

2005-05-04 Thread pavel dot petrovic at gmail dot com

--- Additional Comments From pavel dot petrovic at gmail dot com  
2005-05-04 23:25 ---
Created an attachment (id=8821)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8821&action=view)
the refered file that contains ola2.cpp and ola2.ii


-- 


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


[Bug c++/21393] Internal error: Segmentation Fault (program cc1plus) on a very long cout << ... << command

2005-05-05 Thread pavel dot petrovic at gmail dot com


-- 
   What|Removed |Added

  Known to fail||3.4.3 3.3.5
  Known to work||2.95.2 2.96


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


[Bug c++/26997] New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line

2006-04-03 Thread pavel dot petrovic at gmail dot com
The program below reports the following compiler errors:

bug.cpp:17: error: expected primary-expression before '*' token
bug.cpp:17: error: expected primary-expression before ')' token
bug.cpp:17: error: expected `;' before 'malloc'

which seem to refer to the first occurence of identifier "t"
on the line 17. However, that is a correct occurence.
The mistake is later on the line, but the error message
of the compiler is misleading. This is not a serious issue...

$ uname -a
Linux ... 2.6.12-1-386 #1 Tue Sep 27 12:41:08 JST 2005 i686 GNU/Linux
$ g++ --version
g++ (GCC) 4.0.3 (Debian 4.0.3-1)

libc6: 2.3.6-3
libstdc++6 4.0.3-1

---
#include 

typedef struct { int a; int b; } t;

int main()
{
  t v1, *v2;
  t *v3;

  v2 = &v1;
  v1.a = 2;

// correct code:
//v3 = (t *)malloc(sizeof(t) * v2->a);

// code with a mistake:
  v3 = (t *)malloc(sizeof(t) * t->a);

  return 0;
}
-


-- 
   Summary: g++ reports incorrect error message when the identifier
with error occurs earlier on the same line
   Product: gcc
   Version: 4.0.3
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pavel dot petrovic at gmail dot com


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



[Bug c++/26997] g++ reports misleading error message when the identifier with error occurs earlier on the same line

2006-04-03 Thread pavel dot petrovic at gmail dot com


--- Comment #2 from pavel dot petrovic at gmail dot com  2006-04-03 16:03 
---
(In reply to comment #1)
> types are not expressions though.

sure, but I wouldn't mind that, the compiler complains
about expression, not about type. isn't typecasting
an expression after all?

> It is not incorrect but just misleading.

What you mean by incorrect and what you mean by misleading?
The error message produced by the compiler is definitely not correct.

say you insert this line before line 17:

char *x = (char *)malloc(sizeof(t) * t->a);

you get the following:

bug.cpp:17: error: expected primary-expression before 'char'
bug.cpp:17: error: expected `)' before 'char'
bug.cpp:18: error: expected primary-expression before '*' token
bug.cpp:18: error: expected primary-expression before ')' token
bug.cpp:18: error: expected `;' before 'malloc'

why does the compiler reports problem "before 'char'", if the problem
is far at the other end of the same line?

but this also shows that it is not a problem of the same identifier
at the same line occuring twice - although in that case, we also 
get the ';' error, which we do not get in case of (char *)...?

anyhow, doesn't the behavior indicate some mix up...?


-- 


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