Re: printf() behavior



On Thu, 12 Aug 2010 13:04:55 +0900, "Mark"
<mark_cruzNOTFORSPAM@xxxxxxxxxxx> wrote:


"pete" <pfiland@xxxxxxxxxxxxxx> wrote in message
news:4C635E51.6299@xxxxxxxxxxxxxxxxx
Is the first statement legitimate?

N869
6.3.2.3 Pointers

[#6] Any pointer type may be converted to an integer type.
Except as previously specified, the result is
implementation-defined. If the result cannot be represented
in the integer type, the behavior is undefined. The result
need not be in the range of values of any integer type.


Am I right that in "1" b is evaluated to
address of string literal?

No.


Then who is right, you or Ian Collins (see his answer up the thread) ?

There is no conflict between the two.

In responding to the first question, both say possibly, providing
certain conditions are satisfied. The only difference is the
terminology used.

For the second question, b is an int and therefore does not hold any
address. Only pointers hold addresses. Since the conversion from
pointer to int is implementation-defined (6.3.2.3-6), a definitive
answer can be had only in relation to a specific implementation.


--
Remove del for email
.



Relevant Pages

  • Re: conversions
    ... than or equal to the rank of int and unsigned int. ... supported by an implementation that have lower conversion rank than int. ... "The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type, ...
    (comp.lang.c)
  • Re: Ada Pointer Size Problem
    ... >> int. ... > pointer to an int. ... And you can't assign C pointer to integer without conversion; ... need not provide them if it doesn't have a suitable integer type. ...
    (comp.lang.ada)
  • Re: Moving from C++ to VC++
    ... If it is the longest integer. ... have been bad to constrain fseek to 16 bit int offsets, so they used long, ... 8192 bit integer type is a very special type that is mind-boggling overkill ... Storing pointers in an integer is common enough that the C++ Standard ...
    (microsoft.public.vc.language)
  • Re: promotion and narrowing integer conversion
    ... narrowing conversion? ... int i = INT_MAX; ... converted to the type of the operand with greater rank. ... signed integer type is converted to the type of the operand with unsigned ...
    (comp.lang.c)
  • Re: type conversion float and long
    ... > How does the type conversion work if the expression involves a float ... If an expression involves a float and any integer type, any at all, ... int" is not a qualifier, it is part of the type. ...
    (comp.lang.c)