Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Activity for chris-barry‭

Type On... Excerpt Status Date
Edit Post #277331 Post edited:
Having given more consideration to the implications of the question, I have completely rewritten my answer.
over 3 years ago
Comment Post #277331 @lundin Interestingly, _6.5.6/8_ places restrictions on pointer arithmetic. As a not-too-contrived-example, imagine a user selects from a list numbered from one up. This is used to index a zero-based array. A simple approach would be to create a pointer to element -1 then add the user's selection to ...
(more)
over 3 years ago
Comment Post #277331 @lundin True. The only way to determine that something is undefined is to look at the definition. Your example, however, is inappropriate as it attempts to dereference an out-of-bounds element and the OP says: "even without dereferencing it".
(more)
over 3 years ago
Comment Post #277331 @klutt No. I am saying that it will not compile because you ar trying to assign a value of type char to a variable of type pointer. However, even if the types were made to match (by making arr an array of pointers to char, rather than an array of char) your code sample would not illustrate your quest...
(more)
over 3 years ago
Edit Post #277331 Initial revision over 3 years ago
Answer A: Is it undefined behaviour to just make a pointer point outside boundaries of an array without dereferencing it?
When a compiler encounters the statements ``` char arr[10]; char ptr = &arr[-1] ``` there are three things that it could reasonably do: 1. It can raise an error. 2. It can compile the statements and raise a warning. 3. It can compile the statemnts silently. I think that, in cases...
(more)
over 3 years ago