Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Compiler Warnings
@ 1997-01-18  1:09 Pablo Manalastas
  0 siblings, 0 replies; 8+ messages in thread
From: Pablo Manalastas @ 1997-01-18  1:09 UTC (permalink / raw)


I am trying to compile apache-1.2b4, and everything compiles
properly except for warnings of the type:

"conversion from pointer to integer of different type."

I guess this has to do with the fact that Alpha's pointers are
8 bytes but ints are 4 bytes only.  Can I safely ignore these
warnings (my machine is only 96MB anyway) or must I correct
the ints to longs?

Thank you for your help.

-Pablo-

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
@ 1997-01-18  3:04 Roger
  1997-01-18 17:27 ` Michal Jaegermann
  0 siblings, 1 reply; 8+ messages in thread
From: Roger @ 1997-01-18  3:04 UTC (permalink / raw)


----------
> From: Pablo Manalastas <pmana@tapa.admu.edu.ph>
> To: axp-list@redhat.com
> Subject: Compiler Warnings
> Date: Friday, January 17, 1997 8:09 PM
> 
> I am trying to compile apache-1.2b4, and everything compiles
> properly except for warnings of the type:
> 
> "conversion from pointer to integer of different type."
> 
> I guess this has to do with the fact that Alpha's pointers are
> 8 bytes but ints are 4 bytes only.  Can I safely ignore these
> warnings (my machine is only 96MB anyway) or must I correct
> the ints to longs?
> 
> Thank you for your help.
> 
> -Pablo-
> 
Just ignore the warnings. When you compling as long as you don't
get any errors everything should be ok. I compiled 
apache-1.2b4 with these warnings, but the server is running fine without
any
problems so far.

-Roger

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
       [not found] <199701180109.JAA03936@tapa.admu.edu.ph>
@ 1997-01-18 16:22 ` Richard Henderson
  1997-01-20 11:41 ` Jim Nance
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 1997-01-18 16:22 UTC (permalink / raw)


> "conversion from pointer to integer of different type."
						   ^^^^ size?

> I guess this has to do with the fact that Alpha's pointers are
> 8 bytes but ints are 4 bytes only.  Can I safely ignore these
> warnings (my machine is only 96MB anyway) or must I correct
> the ints to longs?

Depending on what is going on, this can mean you are loosing the
top 64-bits of your pointer, or that someone was trying to be 
clever and not use a union and packed ints into a void* and is
not unpacking them again.

The fact that you only have 96M is immaterial.  All programs are
mapped beginning at 0x120000000 in order to detect 32/64 bit 
problems right away.

r~

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
  1997-01-18  3:04 Roger
@ 1997-01-18 17:27 ` Michal Jaegermann
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Jaegermann @ 1997-01-18 17:27 UTC (permalink / raw)


> 
> > I am trying to compile apache-1.2b4, and everything compiles
> > properly except for warnings of the type:
> > 
> > "conversion from pointer to integer of different type."
> > 
Roger responds:

> Just ignore the warnings.

Sigh!  The best advice to produce broken executables.

You may get lucky sometimes - as the original author did not really
meant "pointer" when s/he wrote that; and conversions **from** integer
**to** pointer can be often ignored.  But converting from a pointer
to integer on axp you are loosing half of yours - possibly significant -
bits.  This makes wonders to your references and a stack.

> I compiled 
> apache-1.2b4 with these warnings, but the server is running fine without
> any problems so far.

Wait and see.  A grail error, which I posted just yesterday, is
most likely caused by somebody following "just ignore the warnings
on integer <-> pointer conversions" principle.

  Michal

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
       [not found] <199701181907.OAA07989@sable.cc.vt.edu>
@ 1997-01-18 20:47 ` Michal Jaegermann
  1997-01-18 21:31 ` Richard Henderson
  1 sibling, 0 replies; 8+ messages in thread
From: Michal Jaegermann @ 1997-01-18 20:47 UTC (permalink / raw)


> 
> Yes I 100% agree with the point that conversion from pointer to interger
> will lose half value of pointer and we should not write any code that way. 
> BUT this is a general rule that applies to normal circumstance. I believe a
> rule can be bent under special/different circumstances.

Possibly.  But you have to investigate that "special circumstances"
do apply and that this propagate correctly through all your code.
I have seen too many broken programs because of that to believe that
this is easy (people who programmed on Atari ST or Amiga, where
sizeof(int) *could* have been 2 and sizeof(void *) was usually 4,
collected quite a bit of battle scars because of that - especially
when porting a code of "all the world is VAX" type).  Another "nice"
thing was a use of int where sizeof_t was really meant.

With more complicated source it is often easier to fix buggy code
(yes, these are definite bugs) then trying later to hunt down results
in a debugger.  Shared libraries make hunts even more interesting. :-)

> need to worry about them.  one of the code that got warning message is:
>     int offset = (int)cmd->info;
> And I don't see any problem with that line unless there is something I
> don't know.

That exactly what you do not know may come back later and get you. :-)

This particular case indeed looks like that it **may** be safe. In
particular if a cast was in original sources.  But this depends how later
'offset' is used and from what.  If values stored there indeed will always
fit into an int then you are OK.  But if an original programmer decided
that s/he may later recover an address from 'offset', because everybody
"knows" that sizeof(int) == sizeof(void *), then you are a goner.

> also another warning is about an integer been passed into a function then
> the function passed this integer as pointer into another function. there
> should not be any problem later if the pointer is converted to interger.

This is more "iffy" case.  If your function expected pointer, there is
no prototype which would force a conversion, and you passed an int,
then you pushed four bytes on an argument stack and grabbed eight.
Now, if there were no other arguments which would become misaligned,
and if you really needed only four bytes of information, and your
code discarded a garbage and not significant bytes, then you will get
away with this (or maybe you will only see later "unaligned access"
wailings).  Otherwise effects are too familiar. :-)

> Other warnings are simliar to the cases I just showed above.

It may be that conversions are harmless in some particular case.
But proving that for non-trivial programs is much harder than it looks.

Another "interesting" gotcha is to access a pointer or long through
a pointer to int.  Unfortunately your compiler may be silent on this
one.

The whole point is that if somebody asks "can I safely disregard
compiler warnings about type conversions" then a general answer is NO.

  Michal

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
       [not found] <199701181907.OAA07989@sable.cc.vt.edu>
  1997-01-18 20:47 ` Michal Jaegermann
@ 1997-01-18 21:31 ` Richard Henderson
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Henderson @ 1997-01-18 21:31 UTC (permalink / raw)


> one of the code that got warning message is:
>     int offset = (int)cmd->info;
> And I don't see any problem with that line unless there is something I
> don't know.

IMHO, that is not playing fair either.  And the amazing bit
is that ISO C gives us a wonderful tool to avoid hacks like
that and is guaranteed to work on all machines: a union.

r~

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
       [not found] <199701180109.JAA03936@tapa.admu.edu.ph>
  1997-01-18 16:22 ` Compiler Warnings Richard Henderson
@ 1997-01-20 11:41 ` Jim Nance
  1 sibling, 0 replies; 8+ messages in thread
From: Jim Nance @ 1997-01-20 11:41 UTC (permalink / raw)


> "conversion from pointer to integer of different type."
> 
> I guess this has to do with the fact that Alpha's pointers are
> 8 bytes but ints are 4 bytes only.  Can I safely ignore these
> warnings (my machine is only 96MB anyway) or must I correct
> the ints to longs?

In general it is NOT safe to ignore warnings like these.  These warnings
are usually caused by missing prototyes.  For example you will get one
if you do something like:

char *str = fgets(buffer, sizeof(buffer), stdin);

and don't include string.h.  The problem is that even though fgets()
returns a char*, if there is no prototype the compiler assumes that
it returns an int.

I don't know about Linux, but Digital Unix puts most things above 4G to
force a segmentation violation if you try something like this.  I
suspect that Linux does too.

Jim

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

* Re: Compiler Warnings
@ 2010-01-18 19:07 Roger
  0 siblings, 0 replies; 8+ messages in thread
From: Roger @ 2010-01-18 19:07 UTC (permalink / raw)


Yes I 100% agree with the point that conversion from pointer to interger
will lose half value of pointer and we should not write any code that way. 
BUT this is a general rule that applies to normal circumstance. I believe a
rule can be bent under special/different circumstances.  This case is one
of these special/different circumsatance.  I believe C compiler gives
warnings to every possible mistakes just to be on the safe side. If you
check the codes that got these warnings you will see that you really don't
need to worry about them.  one of the code that got warning message is:
    int offset = (int)cmd->info;
And I don't see any problem with that line unless there is something I
don't know.
also another warning is about an integer been passed into a function then
the function passed this integer as pointer into another function. there
should not be any problem later if the pointer is converted to interger.
Other warnings are simliar to the cases I just showed above.
And btw I am not someone that "just ignore the warnings on integer <->
pointer conversions" principle.

-Roger

----------
> From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
> To: axp-list@redhat.com
> Subject: Re: Compiler Warnings
> Date: Saturday, January 18, 1997 12:27 PM
> 
> 
> > 
> > > I am trying to compile apache-1.2b4, and everything compiles
> > > properly except for warnings of the type:
> > > 
> > > "conversion from pointer to integer of different type."
> > > 
> Roger responds:
> 
> > Just ignore the warnings.
> 
> Sigh!  The best advice to produce broken executables.
> 
> You may get lucky sometimes - as the original author did not really
> meant "pointer" when s/he wrote that; and conversions **from** integer
> **to** pointer can be often ignored.  But converting from a pointer
> to integer on axp you are loosing half of yours - possibly significant -
> bits.  This makes wonders to your references and a stack.
> 
> > I compiled 
> > apache-1.2b4 with these warnings, but the server is running fine
without
> > any problems so far.
> 
> Wait and see.  A grail error, which I posted just yesterday, is
> most likely caused by somebody following "just ignore the warnings
> on integer <-> pointer conversions" principle.
> 
>   Michal
> 
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

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

end of thread, other threads:[~2010-01-18 19:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <199701180109.JAA03936@tapa.admu.edu.ph>
1997-01-18 16:22 ` Compiler Warnings Richard Henderson
1997-01-20 11:41 ` Jim Nance
2010-01-18 19:07 Roger
     [not found] <199701181907.OAA07989@sable.cc.vt.edu>
1997-01-18 20:47 ` Michal Jaegermann
1997-01-18 21:31 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1997-01-18  3:04 Roger
1997-01-18 17:27 ` Michal Jaegermann
1997-01-18  1:09 Pablo Manalastas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox