public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* possible bug
@ 2003-01-31  0:33 Andrew Morton
  2003-01-31  0:36 ` Jan Hubicka
  0 siblings, 1 reply; 24+ messages in thread
From: Andrew Morton @ 2003-01-31  0:33 UTC (permalink / raw)
  To: gcc

mnm:/home/akpm> cat t.c
void foo(void);

char *bar(void)
{
        return 0;
}

char *zot(void)
{
        return ({foo(); 0; });
}
mnm:/home/akpm> /usr/local/gcc-3.2.1/bin/gcc -O -Wall -c t.c
t.c: In function `zot':
t.c:10: warning: return makes pointer from integer without a cast


I think the warning is bogus?

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Possible Bug
@ 2011-03-26 20:28 Nathan Boley
  2011-03-27  7:38 ` Ian Lance Taylor
  0 siblings, 1 reply; 24+ messages in thread
From: Nathan Boley @ 2011-03-26 20:28 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

Hi All,

In a much larger application, I was getting a weird segfault that an
assignment to a temporary variable fixed. I distilled the example into
the attached "test_case.c". When I run test_case.c under valgrind I
get a memory read error, and it segfaults with electric fence, but I'm
not actually able to get a true segfault. However, I am pretty sure
that the same issue was causing the segfault in my application.

From my really limited assembly knowledge, it looks that on 64 bit
machines gcc is trying to do a full 8 byte read into the register
followed by a 2 byte shift ( instead of 4 then 2 byte read ). If the
two extra bytes are out of bounds it will segfault. This explains why
I get the sporadic segfaults in my bigger application ( where I can
actually be at the page boundary ), but not in the test case.

This only occurs on 64 bit machines, and my gcc version info is:

nboley@ingvas:~/Desktop$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.4.4-14ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-objc-gc --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)

Best,
Nathan Boley

[-- Attachment #2: test_case.c --]
[-- Type: text/x-csrc, Size: 1025 bytes --]

#include <stdio.h>
#include <stdlib.h>

/* Does NOT cause memory error */
typedef struct __attribute__((__packed__))
{
   unsigned short chr;
   unsigned int loc;
} GENOME_LOC_TYPE_2;

/* Causes memory error */
typedef struct __attribute__((__packed__))
{
   unsigned chr            :16;
   unsigned loc            :32;
} GENOME_LOC_TYPE;

void
print_mapped_location( GENOME_LOC_TYPE loc )
{
   printf( "%i\n", loc.loc );
}

int main( int argc, char* argv )
{
   char* data;
   data = malloc(12*sizeof(char));

   GENOME_LOC_TYPE* gen_array
       = (GENOME_LOC_TYPE*) data;
   gen_array[0].loc = 0;
   gen_array[1].loc = 1;

   /* Make sure the structure is actually 6 bytes */
   printf("Gen Loc Type Size: %zu\n", sizeof(GENOME_LOC_TYPE) );

   /* Works fine. */
   printf( "%i\n", gen_array[1].loc );

   /* Works fine */
   GENOME_LOC_TYPE loc = gen_array[1];
   print_mapped_location( loc );

   /* Causes valgrind error */
   /* Cause -lefence segfault */
   print_mapped_location( gen_array[1] );

   free( data );
}

^ permalink raw reply	[flat|nested] 24+ messages in thread
* possible bug
@ 1999-07-25 17:52 Manush Dodunekov
  1999-07-26 10:57 ` Alexandre Oliva
  1999-07-31 23:33 ` Manush Dodunekov
  0 siblings, 2 replies; 24+ messages in thread
From: Manush Dodunekov @ 1999-07-25 17:52 UTC (permalink / raw)
  To: gcc

The code below compiles fine with no flags, but fails to compile with a
parse error on the line containing "iterator i;" when compiling with
-pedantic.

This happens with both egcs-1.1.2 (as shipped on RH6.0/i386) and latest
snapshot (19990718).

Is the code wrong in some way, or is this a bug?

-----------------------
#include <vector>

template <class T>
class X : public vector<T> {
public:
	void f() {
		iterator i;
	}
};

int main(void) 
{
	return 0;
}
---------------------------

thankful for any suggestions,
Manush

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Possible Bug
@ 1997-12-12 15:46 Mike Sullivan
  0 siblings, 0 replies; 24+ messages in thread
From: Mike Sullivan @ 1997-12-12 15:46 UTC (permalink / raw)
  To: egcs

I have tried to compile some fortran code with the binary 
snapshot of pgcc-1.0, If I use the -ggdb flag I get 

Compiling sysdepen.F ...
g77: Internal compiler error: program f771 got fatal signal 6
make: *** [objl/sysdepen.o] Error 1


	I am running Linux on a P-PRO

						Mike Suliivan

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2011-03-29 14:57 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-31  0:33 possible bug Andrew Morton
2003-01-31  0:36 ` Jan Hubicka
2003-01-31  0:56   ` Andrew Morton
2003-01-31  8:08   ` Alexandre Oliva
2003-01-31 10:48     ` Fergus Henderson
  -- strict thread matches above, loose matches on Subject: below --
2011-03-26 20:28 Possible Bug Nathan Boley
2011-03-27  7:38 ` Ian Lance Taylor
2011-03-28 11:06   ` Paolo Bonzini
2011-03-28 11:28     ` Richard Guenther
2011-03-28 11:47       ` Paolo Bonzini
2011-03-28 12:14         ` Richard Guenther
2011-03-28 13:37         ` Michael Matz
2011-03-28 13:54           ` Paolo Bonzini
2011-03-28 14:37             ` Richard Guenther
2011-03-29 16:03               ` Nathan Boley
1999-07-25 17:52 possible bug Manush Dodunekov
1999-07-26 10:57 ` Alexandre Oliva
1999-07-27  3:27   ` Manush Dodunekov
1999-07-27  3:37     ` Alexandre Oliva
1999-07-31 23:33       ` Alexandre Oliva
1999-07-31 23:33     ` Manush Dodunekov
1999-07-31 23:33   ` Alexandre Oliva
1999-07-31 23:33 ` Manush Dodunekov
1997-12-12 15:46 Possible Bug Mike Sullivan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).