Title
Function pointers and subtraction
Status
tc1
Section
7.6.6 [expr.add]
Submitter
Mike Miller

Created on 1999-11-15.00:00:00 last changed 262 months ago

Messages

Date: 2000-10-15.00:00:00

Proposed resolution (10/00):

Remove the words or function from paragraph 8.

Date: 2003-04-25.00:00:00

7.6.6 [expr.add] paragraph 8 explicitly allows subtraction of two pointers to functions:

If two pointers point to the same object or function... and the two pointers are subtracted...
However, 7.6.6 [expr.add] paragraph 2 requires that two pointers that are subtracted be pointers to an object type; function pointers are not allowed.

Being able to subtract two pointers to functions doesn't seem terribly useful, especially considering that subtracting two pointers to different functions appears to produce undefined behavior rather than simply a non-zero result, according to paragraph 6:

Unless both pointers point to elements of the same array object, or one past the last element of the array object, the behavior is undefined.
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetmessages: + msg442
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetstatus: open -> ready
1999-11-15 00:00:00admincreate